You are here

function regcode_schema in Registration codes 6

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

Implementation of hook_schema().

1 call to regcode_schema()
regcode_get_fields in ./regcode.api.php
Load the regcode field definitions from the schema file

File

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

Code

function regcode_schema() {
  $schema['regcode'] = array(
    'description' => t('Hold registration codes'),
    'fields' => array(
      'rid' => array(
        'description' => t('RID'),
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'disp-width' => '11',
        '#exposed' => FALSE,
        '#heading' => t('ID'),
      ),
      'uid' => array(
        'description' => t('User ID'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'disp-width' => '11',
        '#exposed' => FALSE,
        '#heading' => t('UID'),
      ),
      'created' => array(
        'description' => t('Time code was created'),
        'type' => 'datetime',
        'not null' => FALSE,
        '#exposed' => FALSE,
        '#heading' => t('Created'),
      ),
      'lastused' => array(
        'description' => t('Last time this code was used'),
        'type' => 'datetime',
        'not null' => FALSE,
        '#exposed' => FALSE,
        '#heading' => t('Used'),
      ),
      'begins' => array(
        'description' => t('When code should be active from'),
        'type' => 'datetime',
        'not null' => FALSE,
        '#exposed' => TRUE,
        '#heading' => t('Begins'),
      ),
      'expires' => array(
        'description' => t('When code should expire'),
        'type' => 'datetime',
        'not null' => FALSE,
        '#exposed' => TRUE,
        '#heading' => t('Expires'),
      ),
      'category' => array(
        'description' => t('A grouping category to help management'),
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
        '#exposed' => TRUE,
        '#heading' => t('Category'),
      ),
      'code' => array(
        'description' => t('The registration code'),
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
        '#exposed' => TRUE,
        '#heading' => t('Code'),
      ),
      'is_active' => array(
        'description' => t('Whether the code is active'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
        'disp-width' => '1',
        '#exposed' => TRUE,
        '#heading' => t('Enabled'),
      ),
      'maxuses' => array(
        'description' => t('Maximum times the code can be used'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
        'disp-width' => '11',
        '#exposed' => TRUE,
        '#heading' => t('Max'),
      ),
      'uses' => array(
        'description' => t('Number of times the code has been used'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'disp-width' => '11',
        '#exposed' => TRUE,
        '#heading' => t('Uses'),
      ),
    ),
    'primary key' => array(
      'rid',
    ),
    'unique keys' => array(
      'code' => array(
        'code',
      ),
    ),
    'indexes' => array(
      'begins' => array(
        'begins',
      ),
      'category' => array(
        'category',
      ),
      'expires' => array(
        'expires',
      ),
    ),
  );
  return $schema;
}