You are here

function regcode_schema in Registration codes 7

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

Implements hook_schema().

File

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

Code

function regcode_schema() {

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

  // Definition for the regcode_term table.
  $schema['regcode_term'] = array(
    'description' => 'Map registration codes and taxonomy',
    'fields' => array(
      'id' => array(
        'description' => 'ID',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'rid' => array(
        'description' => 'Regcode ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'tid' => array(
        'description' => 'Term ID',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      'regcode_term' => array(
        'rid',
        'tid',
      ),
    ),
  );
  return $schema;
}