You are here

function commerce_customer_schema in Commerce Core 7

Implements hook_schema().

File

modules/customer/commerce_customer.install, line 6

Code

function commerce_customer_schema() {
  $schema = array();
  $schema['commerce_customer_profile'] = array(
    'description' => 'The base table for customer profiles.',
    'fields' => array(
      'profile_id' => array(
        'description' => 'The primary identifier for a customer profile.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'revision_id' => array(
        'description' => 'The current {commerce_customer_profile_revision}.revision_id version identifier.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'type' => array(
        'description' => 'The {commerce_customer_profile_type}.type of this profile.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'uid' => array(
        'description' => 'The {users}.uid that this profile belongs to.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => 'Boolean indicating whether the profile is active or not.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the profile was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the profile was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'data' => array(
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of additional data.',
      ),
    ),
    'primary key' => array(
      'profile_id',
    ),
    'unique keys' => array(
      'revision_id' => array(
        'revision_id',
      ),
    ),
    'indexes' => array(
      'uid' => array(
        'uid',
      ),
      'customer_profile_type' => array(
        'type',
      ),
      'uid_by_type' => array(
        'uid',
        'type',
      ),
    ),
    'foreign keys' => array(
      'customer_profile_revision' => array(
        'table' => 'commerce_customer_profile_revision',
        'columns' => array(
          'revision_id' => 'revision_id',
        ),
      ),
      'owner' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
    ),
  );
  $schema['commerce_customer_profile_revision'] = array(
    'description' => 'Saves information about each saved revision of a {commerce_customer_profile}.',
    'fields' => array(
      'profile_id' => array(
        'description' => 'The {commerce_customer_profile}.customer_id of the profile this revision belongs to.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      '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 created this profile at this revision.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => 'Boolean indicating whether the profile is active or not.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      '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,
      ),
      '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(
      'profile_id' => array(
        'profile_id',
      ),
    ),
    'foreign keys' => array(
      'customer_profile' => array(
        'table' => 'commerce_customer_profile',
        'columns' => array(
          'profile_id' => 'profile_id',
        ),
      ),
      'creator' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
    ),
  );
  return $schema;
}