You are here

function commerce_line_item_schema in Commerce Core 7

Implements hook_schema().

File

modules/line_item/commerce_line_item.install, line 6

Code

function commerce_line_item_schema() {
  $schema = array();
  $schema['commerce_line_item'] = array(
    'description' => 'The base table for line items.',
    'fields' => array(
      'line_item_id' => array(
        'description' => 'The primary identifier for a line item.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'order_id' => array(
        'description' => 'The unique ID of the order the line item belongs to.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'type' => array(
        'description' => 'The module defined type of this line item.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'line_item_label' => array(
        'description' => 'The merchant defined label for a line item.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'quantity' => array(
        'type' => 'numeric',
        'size' => 'normal',
        'not null' => TRUE,
        'default' => 0,
        'precision' => 10,
        'scale' => 2,
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the line item was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the line item 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(
      'line_item_id',
    ),
    'indexes' => array(
      'order_id' => array(
        'order_id',
      ),
      'line_item_type' => array(
        'type',
      ),
    ),
    'foreign keys' => array(
      'order_id' => array(
        'table' => 'commerce_order',
        'columns' => array(
          'order_id' => 'order_id',
        ),
      ),
    ),
  );
  return $schema;
}