You are here

function node_registration_schema in Node registration 7

Implements hook_schema().

Define 2 tables: node_registration, node_registration_node.

File

./node_registration.install, line 28
Install, uninstall, enable and disable hooks and schema.

Code

function node_registration_schema() {
  $schema['node_registration'] = array(
    'description' => 'The base table for node_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 bundle type of this registration.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'node_type' => array(
        'description' => "The node type of this registrations.",
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'nid' => array(
        'description' => 'The id of the entity this registration is associated with.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'email' => array(
        'description' => "User's e-mail address.",
        'type' => 'varchar',
        'length' => 254,
        'not null' => TRUE,
        'default' => '',
      ),
      'slots' => array(
        'description' => 'How many slots this registration should use towards the total capacity for this event.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
      ),
      'author_uid' => array(
        'description' => 'The uid of the user who created this registration.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'uid' => array(
        'description' => 'The uid of the registree.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      '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,
      ),
      'attended' => array(
        'description' => 'Whether the registree attended the event.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'secret' => array(
        'description' => 'A secret for anonymous users to cancel etc with.',
        'type' => 'varchar',
        'length' => 40,
        'not null' => TRUE,
        'default' => '',
      ),
      'reminder_sent' => array(
        'description' => 'The timestamp when a reminder was sent to the registree.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'verified' => array(
        'description' => 'Whether the user was verified.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'cancelled' => array(
        'description' => 'The timestamp when this registration was cancelled.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'waitinglist' => array(
        'description' => 'Whether this registration is on the waitinglist.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'weight' => array(
        'description' => 'Used for waitinglist execution order and display.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'registration_updated' => array(
        'updated',
      ),
      'registration_created' => array(
        'created',
      ),
      'registration_type' => array(
        array(
          'type',
          4,
        ),
      ),
      'registration_cancelled' => array(
        'cancelled',
      ),
    ),
    'foreign keys' => array(
      'registration_node' => array(
        'table' => 'node',
        'columns' => array(
          'nid' => 'nid',
        ),
      ),
      'registration_author' => array(
        'table' => 'users',
        'columns' => array(
          'author_uid' => 'uid',
        ),
      ),
    ),
    'unique keys' => array(),
    'primary key' => array(
      'registration_id',
    ),
  );
  $schema['node_registration_node'] = array(
    'description' => 'Node registration node settings.',
    'fields' => array(
      'nid' => array(
        'description' => 'Node id these registration settings are for.',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'capacity' => array(
        'description' => 'Maximum number of users who can signup for this event.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'status' => array(
        'description' => 'Boolean indicating if signups are open (1) or closed (0) for the given node',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
      ),
      'start_date' => array(
        'description' => 'DEPRECATED: Start date (opening) of registrations',
        'type' => 'text',
        'mysql_type' => 'date',
        'pgsql_type' => 'date',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'private_fields' => array(
        'description' => 'Whether this node has node specific fields.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => 0,
      ),
      'settings' => array(
        'type' => 'blob',
        'not null' => TRUE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized object that stores additional registration settings.',
      ),
    ),
    'foreign keys' => array(
      'registration_node_node' => array(
        'table' => 'node',
        'columns' => array(
          'nid' => 'nid',
        ),
      ),
    ),
    'primary key' => array(
      'nid',
    ),
  );
  return $schema;
}