You are here

function registration_schema in Entity Registration 7.2

Same name and namespace in other branches
  1. 8.2 registration.install \registration_schema()
  2. 8 registration.install \registration_schema()
  3. 7 registration.install \registration_schema()

Implements hook_schema().

File

./registration.install, line 11
Schema and installation hooks for registration module.

Code

function registration_schema() {
  $schema['registration'] = array(
    'description' => 'The base table for registration module.',
    'fields' => array(
      'registration_id' => array(
        'description' => 'The primary identifier for a registration.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'type' => array(
        'description' => 'The {registration_type}.type of this registration.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'entity_id' => array(
        'description' => 'The id of the entity this registration is associated with.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'entity_type' => array(
        'description' => 'The entity type of the entity this registration is associated with.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'anon_mail' => array(
        'type' => 'varchar',
        'length' => 254,
        'not null' => FALSE,
        'description' => "Anonymous registrant's e-mail address.",
      ),
      'count' => array(
        'description' => 'How many spaces this registration should use towards the total capacity for this event.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
      ),
      'registrant_id' => array(
        'description' => 'The entity id of the registrant associated with this registration.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => 0,
      ),
      'author_uid' => array(
        'description' => 'The uid of the user who created this registration.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'state' => array(
        'description' => 'The {registration_state}.name of this registration.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the registration was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'updated' => array(
        'description' => 'The Unix timestamp when the registration was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'registration_updated' => array(
        'updated',
      ),
      'registration_created' => array(
        'created',
      ),
      'registration_type' => array(
        array(
          'type',
          4,
        ),
      ),
      'registration_state' => array(
        'state',
      ),
    ),
    'foreign keys' => array(
      'registration_author' => array(
        'table' => 'users',
        'columns' => array(
          'author_uid' => 'uid',
        ),
      ),
      'registration_state' => array(
        'table' => 'registration_state',
        'columns' => array(
          'state' => 'name',
        ),
      ),
    ),
    'primary key' => array(
      'registration_id',
    ),
  );
  $schema['registration_entity'] = array(
    'description' => 'Registration per-entity settings.',
    'fields' => array(
      'entity_id' => array(
        'description' => 'Entity id these registration settings are for.',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'entity_type' => array(
        'description' => 'The entity type of the entity these registration settings are for.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'capacity' => array(
        'description' => 'Maximum number of registrants who can sign up for this event.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => 'Boolean indicating if registrations are open (1) or closed (0) for the given entity',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
      ),
      'send_reminder' => array(
        'description' => 'Boolean indicating whether reminder emails should be sent. This is set to 0 once the reminders are sent.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'reminder_date' => array(
        'description' => 'Date to send the reminder on.',
        'type' => 'datetime',
        'mysql_type' => 'datetime',
        'pgsql_type' => 'timestamp',
        'sqlite_type' => 'varchar',
        'sqlsrv_type' => 'smalldatetime',
        'not null' => FALSE,
      ),
      'reminder_template' => array(
        'description' => 'Reminder email template.',
        'type' => 'text',
        'size' => 'big',
        'not null' => FALSE,
      ),
      'open' => array(
        'description' => 'Date to open registrations. Or NULL to open immediately.',
        'type' => 'datetime',
        'mysql_type' => 'datetime',
        'pgsql_type' => 'timestamp',
        'sqlite_type' => 'varchar',
        'sqlsrv_type' => 'smalldatetime',
        'not null' => FALSE,
      ),
      'open_date_token' => array(
        'description' => 'Token value to determine open date.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'close' => array(
        'description' => 'Date to close registrations. Or NULL to never close automatically.',
        'type' => 'datetime',
        'mysql_type' => 'datetime',
        'pgsql_type' => 'timestamp',
        'sqlite_type' => 'varchar',
        'sqlsrv_type' => 'smalldatetime',
        'not null' => FALSE,
      ),
      'close_date_token' => array(
        'description' => 'Token value to determine close date.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'settings' => array(
        'type' => 'blob',
        'not null' => TRUE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized object that stores additional registration settings.',
      ),
    ),
    'primary key' => array(
      'entity_id',
      'entity_type',
    ),
  );
  $schema['registration_type'] = array(
    'description' => 'Stores information about all defined registration types.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique registration type ID.',
      ),
      'name' => array(
        'description' => 'The machine-readable name of this registration type.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'label' => array(
        'description' => 'The human-readable name of this registration 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 registration type in relation to others.',
      ),
      'locked' => array(
        'description' => 'A boolean indicating whether the administrator may delete this type.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
      ),
      'default_state' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => FALSE,
        'description' => 'The machine name of the default registration state.',
      ),
      'data' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of additional data related to this entity_test type.',
        'merge' => TRUE,
      ),
      'status' => array(
        'type' => 'int',
        'not null' => TRUE,
        // Set the default to ENTITY_CUSTOM without using the constant as it is
        // not safe to use it at this point.
        'default' => 0x1,
        'size' => 'tiny',
        'description' => 'The exportable status of the entity.',
      ),
      'module' => array(
        'description' => 'The name of the providing module if the entity has been defined in code.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
      'registrant_entity_type' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => 'user',
        'description' => 'The machine name of the registrant entity\'s type.',
      ),
      'registrant_bundle' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => 'user',
        'description' => 'The machine name of the registrant entity\'s bundle.',
      ),
      'registrant_email_property' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => 'mail',
        'description' => 'The machine name of the registrant entity\'s email property.',
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'unique keys' => array(
      'name' => array(
        'name',
      ),
    ),
  );
  $schema['registration_state'] = array(
    'description' => 'Stores registration states configuration.',
    'fields' => array(
      'registration_state_id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The registration state ID.',
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'description' => 'The machine name of the registration state.',
      ),
      'label' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'description' => 'The human readable name of the registration state.',
      ),
      'description' => array(
        'type' => 'text',
        'size' => 'big',
        'not null' => FALSE,
        'description' => 'The description of the registration state.',
      ),
      'default_state' => array(
        'description' => 'A boolean indicating default registration state.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
      ),
      'active' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'A flag showing active registration states.',
      ),
      'held' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'A flag showing held registration states.',
      ),
      'show_on_form' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'A flag showing if this registration state should be shown on the registration form.',
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The weight of this  registration state in the UI',
      ),
      'status' => array(
        'type' => 'int',
        'not null' => TRUE,
        // Set the default to ENTITY_CUSTOM without using the constant as it is
        // not safe to use it at this point.
        'default' => 0x1,
        'size' => 'tiny',
        'description' => 'The exportable status of the entity.',
      ),
      'module' => array(
        'description' => 'The name of the providing module if the entity has been defined in code.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => FALSE,
      ),
    ),
    'indexes' => array(
      'registration_state_name' => array(
        'name',
      ),
      'registration_state_default_state' => array(
        'default_state',
      ),
    ),
    'primary key' => array(
      'registration_state_id',
    ),
    'unique keys' => array(
      'name' => array(
        'name',
      ),
    ),
  );

  // Create cache bins for Entity-cache module.
  $cache_schema = drupal_get_schema_unprocessed('system', 'cache');
  $types = array(
    'registration',
    'registration_type',
    'registration_state',
  );
  foreach ($types as $type) {
    $schema["cache_entity_{$type}"] = $cache_schema;
    $schema["cache_entity_{$type}"]['description'] = "Cache table used to store {$type} entity records.";
  }
  return $schema;
}