You are here

function regcode_schema in Registration codes 8

Same name and namespace in other branches
  1. 6.2 regcode.install \regcode_schema()
  2. 6 regcode.install \regcode_schema()
  3. 7.2 regcode.install \regcode_schema()
  4. 7 regcode.install \regcode_schema()

Implements hook_schema().

File

./regcode.install, line 11
Install, uninstall and scheme functions for the regcode module.

Code

function regcode_schema() {

  // Definition for the regcode table.
  $schema['regcode'] = [
    'description' => 'Hold registration codes',
    'fields' => [
      'rid' => [
        'description' => 'RID',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'uid' => [
        'description' => 'User ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ],
      'created' => [
        'description' => 'Code creation time',
        'type' => 'int',
        'not null' => FALSE,
      ],
      'lastused' => [
        'description' => 'Code last used time',
        'type' => 'int',
        'not null' => FALSE,
      ],
      'begins' => [
        'description' => 'Code activation date',
        'type' => 'int',
        'not null' => FALSE,
      ],
      'expires' => [
        'description' => 'Code expiry date',
        'type' => 'int',
        'not null' => FALSE,
      ],
      'code' => [
        'description' => 'The registration code',
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ],
      'is_active' => [
        'description' => 'Whether the code is active',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ],
      'maxuses' => [
        'description' => 'Maximum times a code can be used',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ],
      'uses' => [
        'description' => 'Number of times the code has been used',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
    ],
    'primary key' => [
      'rid',
    ],
    'unique keys' => [
      'code' => [
        'code',
      ],
    ],
  ];
  return $schema;
}