You are here

function commerce_option_schema in Commerce Product Option 7.2

Same name and namespace in other branches
  1. 7 commerce_option.install \commerce_option_schema()

Implements hook_schema().

File

./commerce_option.install, line 6

Code

function commerce_option_schema() {
  $schema = array();
  $schema['commerce_option'] = array(
    'description' => 'The base table for option lines.',
    'fields' => array(
      'option_id' => array(
        'description' => 'The primary identifier for the option.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'set_id' => array(
        'description' => 'The {commerce_option_set}.set_id of this.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'product_id' => array(
        'description' => 'The {commerce_product}.product_id which is linked with this option.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'line_item_id' => array(
        'description' => 'The {commerce_line_item}.line_item_id that is linked with this option.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the option was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the product 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(
      'option_id',
    ),
    'indexes' => array(
      'set_id' => array(
        'set_id',
      ),
      'line_item_id' => array(
        'line_item_id',
      ),
    ),
    'foreign keys' => array(
      'line_item' => array(
        'table' => 'commerce_line_item',
        'columns' => array(
          'line_item_id' => 'line_item_id',
        ),
      ),
    ),
  );
  $schema['commerce_option_set'] = array(
    'description' => 'Stores information about {commerce_option} sets.',
    'fields' => array(
      'option_set_id' => array(
        'description' => 'The primary identifier for the option set.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'set_id' => array(
        'description' => 'The machine-readable name of this set.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'name' => array(
        'description' => 'The human-readable name of this set.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'description' => array(
        'description' => 'A brief description of this set.',
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'medium',
      ),
      'data' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of additional data related to this option set.',
      ),
      'status' => array(
        'type' => 'int',
        'not null' => TRUE,
        // Set the default to ENTITY_CUSTOM without using the constant as it is
        // not safe to use it at this point.
        'default' => 0x1,
        'size' => 'tiny',
        'description' => 'The exportable status of the entity.',
      ),
      'module' => array(
        'description' => 'The name of the providing module if the entity has been defined in code.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'option_set_id',
    ),
  );
  return $schema;
}