You are here

function commerce_order_schema in Commerce Core 7

Implements hook_schema().

File

modules/order/commerce_order.install, line 6

Code

function commerce_order_schema() {
  $schema = array();
  $schema['commerce_order'] = array(
    'description' => 'The base table for orders.',
    'fields' => array(
      'order_id' => array(
        'description' => 'The primary identifier for an order.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'order_number' => array(
        'description' => 'The order number displayed to the customer.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'revision_id' => array(
        'description' => 'The current {commerce_order_revision}.revision_id version identifier.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'type' => array(
        'description' => 'The type of this order.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'uid' => array(
        'description' => 'The {users}.uid that owns this order.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'mail' => array(
        'description' => 'The e-mail address associated with the order.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'status' => array(
        'description' => 'The status name of this order.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the order was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the order was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'placed' => array(
        'description' => 'The Unix timestamp when the order was placed e.g. when checkout was completed.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'hostname' => array(
        'description' => 'The IP address that created this order.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'data' => array(
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of additional data.',
      ),
    ),
    'primary key' => array(
      'order_id',
    ),
    'unique keys' => array(
      'order_number' => array(
        'order_number',
      ),
      'revision_id' => array(
        'revision_id',
      ),
    ),
    'indexes' => array(
      'uid' => array(
        'uid',
      ),
      'status' => array(
        'status',
      ),
      'order_id_uid_status' => array(
        'order_id',
        'uid',
        'status',
      ),
    ),
    'foreign keys' => array(
      'current_revision' => array(
        'table' => 'commerce_order_revision',
        'columns' => array(
          'revision_id' => 'revision_id',
        ),
      ),
      'owner' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
    ),
  );
  $schema['commerce_order_revision'] = array(
    'description' => 'Saves information about each saved revision of a {commerce_order}.',
    'fields' => array(
      'order_id' => array(
        'description' => 'The {commerce_order}.order_id of the order this revision belongs to.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'order_number' => array(
        'description' => 'The order number displayed to the customer for this revision.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'revision_id' => array(
        'description' => 'The primary identifier for this revision.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'revision_uid' => array(
        'description' => 'The {users}.uid that owns the order at this revision.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'mail' => array(
        'description' => 'The e-mail address associated with the order at this revision.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'status' => array(
        'description' => 'The status name of this revision.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
      ),
      'log' => array(
        'description' => 'The log entry explaining the changes in this version.',
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
      ),
      'revision_timestamp' => array(
        'description' => 'The Unix timestamp when this revision was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'revision_hostname' => array(
        'description' => 'The IP address that created this order.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'data' => array(
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of additional data.',
      ),
    ),
    'primary key' => array(
      'revision_id',
    ),
    'indexes' => array(
      'order_id' => array(
        'order_id',
      ),
    ),
    'foreign keys' => array(
      'order' => array(
        'table' => 'commerce_order',
        'columns' => array(
          'order_id' => 'order_id',
        ),
      ),
      'owner' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
    ),
  );
  return $schema;
}