You are here

function commerce_cardonfile_schema in Commerce Card on File 7.2

Same name and namespace in other branches
  1. 7 commerce_cardonfile.install \commerce_cardonfile_schema()

Implements hook_schema().

File

./commerce_cardonfile.install, line 21
Installs the tables required by Commerce Card on File.

Code

function commerce_cardonfile_schema() {
  $schema = array();
  $schema['commerce_cardonfile'] = array(
    'description' => 'The base table for the commerce_cardonfile entity type.',
    'fields' => array(
      'card_id' => array(
        'description' => 'Primary key: numeric card id.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'description' => 'The {users}.uid of the card owner.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'order_id' => array(
        'description' => 'The {commerce_order}.order_id that originally supplied this card data, if card data was created from checkout.',
        'type' => 'int',
        'unsigned' => TRUE,
      ),
      'payment_method' => array(
        'description' => 'The method_id of the payment method that stored the card.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
      ),
      'instance_id' => array(
        'description' => 'The instance_id of the payment method that stored the card.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'remote_id' => array(
        'description' => 'The id of the card at the payment gateway.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'card_type' => array(
        'description' => 'The card type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'card_name' => array(
        'description' => 'The name on the card.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'card_number' => array(
        'description' => 'Truncated card number (last 4 digits).',
        'type' => 'varchar',
        'length' => 4,
        'not null' => TRUE,
        'default' => '',
      ),
      'card_exp_month' => array(
        'description' => 'Expiration month.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'card_exp_year' => array(
        'description' => 'Expiration year.',
        'type' => 'int',
        'size' => 'small',
        'not null' => TRUE,
        'default' => 0,
      ),
      'instance_default' => array(
        'description' => 'Whether this is the default card for this payment method instance.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => 'Card status: inactive (0), active (1), not deletable (2), declined (3).',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the card was first stored.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the card was last updated.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'card_id',
    ),
    'indexes' => array(
      'uid' => array(
        'uid',
      ),
      'order_id' => array(
        'order_id',
      ),
      'instance_id' => array(
        'instance_id',
      ),
    ),
    'foreign keys' => array(
      'creator' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
      'order' => array(
        'table' => 'commerce_order',
        'columns' => array(
          'order_id' => 'order_id',
        ),
      ),
    ),
  );
  return $schema;
}