You are here

function newsletter_subscriber_schema in Newsletter 7.2

Implements hook_schema().

File

modules/subscriber/newsletter_subscriber.install, line 77
Sets up the base table for newsletter subscribers and a table to store information about the subscriber types, install, uninstall and update functions for Newsletter subscriber module.

Code

function newsletter_subscriber_schema() {
  $schema = array();
  $schema['newsletter_subscriber'] = array(
    'description' => 'The base table for newsletter subscribers.',
    'fields' => array(
      'subscriber_id' => array(
        'description' => 'Primary Key: Identifier for a newsletter subscriber.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'type' => array(
        'description' => 'The {newsletter_subscriber_type}.type of this subscriber.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'language' => array(
        'description' => 'The {languages}.language of the subscriber.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'uid' => array(
        'description' => 'The {users}.uid of the subscriber, 0 if anonymous.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'mail' => array(
        'description' => 'The subscriber\'s email.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'hostname' => array(
        'description' => 'Subscriber\'s IP, when he/she subscribed.',
        'type' => 'varchar',
        'length' => 22,
        'not null' => FALSE,
      ),
      'hash' => array(
        'description' => 'Subscriber\'s hash, used to confirm subscription and unsubscribe.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
      ),
      'status' => array(
        'description' => 'Status of the subscriber, 0 for inactive/unconfirmed, 1 for active.',
        'type' => 'int',
        'not null' => TRUE,
        'size' => 'tiny',
        'default' => 0,
      ),
      'confirmation_timestamp' => array(
        'description' => 'This subscriber confirmation timestamp of his/her mail.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'created' => array(
        'description' => 'The Unix timestamp when the subscriber was created.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'The Unix timestamp when the subscriber was most recently saved.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'subscriber_id',
    ),
    'indexes' => array(
      'subscriber_type' => array(
        'type',
      ),
      'subscriber_hash' => array(
        'hash',
      ),
      'subscriber_uid' => array(
        'uid',
      ),
    ),
    'foreign keys' => array(
      'subscriber_user' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
    ),
    'unique keys' => array(
      'subscriber_mail' => array(
        'mail',
      ),
    ),
  );
  $schema['newsletter_subscriber_type'] = array(
    'description' => 'Stores information about created {newsletter_subscriber} types.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: Unique subscriber type identifier.',
      ),
      'type' => array(
        'description' => 'The machine-readable name of this subscriber type.',
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ),
      'name' => array(
        'description' => 'The human-readable name of this subscriber type.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'description' => array(
        'description' => 'A brief description of this subscriber type.',
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'medium',
      ),
      'weight' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'The weight of this subscriber type in relation to others.',
      ),
      'data' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of additional data related to this subscriber type.',
      ),
    ) + entity_exportable_schema_fields(),
    'primary key' => array(
      'id',
    ),
    'unique keys' => array(
      'type' => array(
        'type',
      ),
    ),
  );
  return $schema;
}