You are here

function commerce_option_schema in Commerce Product Option 7

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

Implements hook_schema().

File

./commerce_option.install, line 7

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,
      ),
      'field_name' => array(
        'description' => 'The {commerce_product} field_name which is linked with this option.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'field_delta' => array(
        'description' => 'The {commerce_product} field delta 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',
      ),
    ),
    '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(
      '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.',
      ),
    ),
    'primary key' => array(
      'set_id',
    ),
  );
  return $schema;
}