You are here

function commerce_coupon_schema in Commerce Coupon 7

Same name and namespace in other branches
  1. 7.2 commerce_coupon.install \commerce_coupon_schema()

Implements hook_schema().

File

./commerce_coupon.install, line 11
Install, update and uninstall functions for the commerce_coupon module.

Code

function commerce_coupon_schema() {
  $schema['commerce_coupon'] = array(
    'description' => 'The base table for coupons.',
    'fields' => array(
      'coupon_id' => array(
        'description' => 'The primary identifier for the coupon.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'type' => array(
        'description' => 'The {commerce_coupon_type}.type of this coupon.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'is_active' => array(
        'description' => 'Indicates if this coupon is active or not.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the coupon was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the coupon was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'data' => array(
        'type' => 'blob',
        'size' => 'big',
        'not null' => FALSE,
        'serialize' => TRUE,
        'description' => 'Everything else, serialized.',
      ),
    ),
    'primary key' => array(
      'coupon_id',
    ),
  );
  $schema['commerce_coupon_type'] = array(
    'description' => 'Stores information about all defined coupon types.',
    'fields' => array(
      'type' => array(
        'description' => 'The machine-readable name of this coupon type.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'label' => array(
        'description' => 'The human-readable name of this coupon type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'The weight of this coupon type in relation to others.',
      ),
      'data' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of additional data related to this coupon type.',
      ),
    ) + commerce_coupon_exportable_schema_fields(),
    'primary key' => array(
      'type',
    ),
  );
  return $schema;
}