function commerce_discount_schema in Commerce Discount 7
Implements hook_schema().
File
- ./
commerce_discount.install, line 18 - Install, update, and uninstall functions for the commerce discount module.
Code
function commerce_discount_schema() {
$schema['commerce_discount'] = array(
'description' => 'The base table for discounts.',
'fields' => array(
'discount_id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'The internal identifier for any discount.',
),
'name' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'description' => 'The machine name of the discount.',
'default' => '',
),
'label' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => 'The label of the discount.',
'default' => '',
),
'type' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => 'The discount type (bundle).',
'default' => '',
),
'status' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 1,
'size' => 'tiny',
'description' => 'Whether the discount is enabled.',
),
'export_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,
),
'component_title' => array(
'description' => 'The component price title',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
'sort_order' => array(
'description' => 'The discount sort order.',
'type' => 'int',
'not null' => TRUE,
'default' => 10,
'size' => 'tiny',
),
),
'primary key' => array(
'discount_id',
),
'unique keys' => array(
'name' => array(
'name',
),
),
);
$schema['commerce_discount_offer'] = array(
'description' => 'The base table for discount offers.',
'fields' => array(
'discount_offer_id' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'The internal identifier for any discount offer.',
),
'type' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => 'The discount offer type (bundle).',
'default' => '',
),
),
'primary key' => array(
'discount_offer_id',
),
);
$schema['commerce_discount_usage'] = array(
'fields' => array(
'discount' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'description' => 'Discount name.',
),
'mail' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'The email of the customer that used this discount.',
),
'order_id' => array(
'type' => 'int',
'not null' => TRUE,
'description' => 'The order id that this discount was used with.',
),
),
'unique keys' => array(
'discount_mail_order_id' => array(
'discount',
'mail',
'order_id',
),
),
'foreign keys' => array(
'discount' => array(
'table' => 'commerce_discount',
'columns' => array(
'discount' => 'name',
),
),
'order_id' => array(
'table' => 'commerce_order',
'columns' => array(
'order_id' => 'order_id',
),
),
'mail' => array(
'table' => 'users',
'columns' => array(
'mail' => 'mail',
),
),
),
'indexes' => array(
'mail' => array(
'mail',
),
'discount' => array(
'discount',
),
'order_id' => array(
'order_id',
),
),
);
return $schema;
}