You are here

function newsletter_schema in Newsletter 7

Same name and namespace in other branches
  1. 7.2 newsletter.install \newsletter_schema()

Implements hook_schema().

File

./newsletter.install, line 101
Contains install,uninstall and update functions for Newsletter module.

Code

function newsletter_schema() {
  $schema = array();
  $schema['newsletter_subscriber'] = array(
    'description' => 'Contains the subscriber emails with their list relations.',
    'fields' => array(
      'nsid' => array(
        'description' => 'The primary identifier for a subscriber.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'description' => 'The user id (if the user is registered) of the subscriber.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'email' => array(
        'description' => 'The subscriber\'s email.',
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
      ),
      'firstname' => array(
        'description' => 'The subscriber\'s full name.',
        'type' => 'varchar',
        'length' => 64,
        'not null' => FALSE,
      ),
      'lastname' => array(
        'description' => 'The subscriber\'s full name.',
        'type' => 'varchar',
        'length' => 64,
        'not null' => FALSE,
      ),
      'gender' => array(
        'description' => 'The subscriber\'s gender.',
        'type' => 'varchar',
        'length' => 24,
        'not null' => FALSE,
      ),
      'receive_format' => array(
        'description' => 'The subscriber\'s Preferred newsletter format.',
        'type' => 'varchar',
        'length' => 11,
        'not null' => FALSE,
      ),
      'ip' => 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,
      ),
      'confirmed' => array(
        'description' => 'Whether this user has confirm his subscription through email.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'confirmation_timestamp' => array(
        'description' => 'The confirmation timestamp of this subscriber.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'created' => array(
        'description' => 'The creation timestamp of this subscriber.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'subscriber_created' => array(
        'created',
      ),
    ),
    'unique keys' => array(
      'subscriber_email' => array(
        'email',
      ),
      'subscriber_uid' => array(
        'uid',
      ),
    ),
    'primary key' => array(
      'nsid',
    ),
  );
  $schema['newsletter_list'] = array(
    'description' => 'Contains the newsletter subscriber lists with their templates relations.',
    'fields' => array(
      'nlid' => array(
        'description' => 'The unique ID of this list.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'title' => array(
        'description' => 'The list\'s title.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'send_rate' => array(
        'description' => 'How often to send this list.Manual,Daily,Weekly or Monthly.',
        'type' => 'varchar',
        'length' => 11,
        'not null' => TRUE,
        'default' => 'Manual',
      ),
      'last_sent' => array(
        'description' => 'Timestamp this list was last sent.',
        'type' => 'int',
        'not null' => FALSE,
      ),
      'send_again' => array(
        'description' => 'Date this list needs to be sent again.',
        'mysql_type' => 'date',
        'pgsql_type' => 'timestamp',
        'sqlsrv_type' => 'date',
        'type' => NULL,
        'not null' => FALSE,
      ),
      'created' => array(
        'description' => 'The creation timestamp of this subscriber.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => 0,
      ),
    ),
    'unique keys' => array(
      'list_title' => array(
        'title',
      ),
    ),
    'foreign keys' => array(
      'tracked_template' => array(
        'table' => 'newsletter_template',
        'columns' => array(
          'ntid' => 'ntid',
        ),
      ),
    ),
    'indexes' => array(
      'list_created' => array(
        'created',
      ),
    ),
    'primary key' => array(
      'nlid',
    ),
  );
  $schema['newsletter_template'] = array(
    'description' => 'Contains the newsletter templates.',
    'fields' => array(
      'ntid' => array(
        'description' => 'The unique ID of this template.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'subject' => array(
        'description' => 'The template\'s title/subject .',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'basic' => array(
        'description' => 'Whether this template is basic or not.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => 0,
      ),
      'exposed' => array(
        'description' => 'Boolean.whether this list is exposed or not',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'created' => array(
        'description' => 'The creation timestamp of this template.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => 0,
      ),
    ),
    'unique keys' => array(
      'template_subject' => array(
        'subject',
      ),
    ),
    'indexes' => array(
      'template_created' => array(
        'created',
      ),
    ),
    'primary key' => array(
      'ntid',
    ),
  );
  $schema['newsletter_newsletter'] = array(
    'description' => 'Contains the newsletters that are sent with their statistics.',
    'fields' => array(
      'nnid' => array(
        'description' => 'The primary identifier for a newsletter.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'title' => array(
        'description' => 'The newsletter\'s title.(If this newsletter is automatic then it gets its list title)',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'send_id' => array(
        'description' => 'The # of sent times.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => 0,
      ),
      'custom' => array(
        'description' => 'Whether this newsletter sent as a custom one.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'ntid' => array(
        'description' => 'The {newsletter_templates}.id this newsletter uses.',
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'subscribers_sent' => array(
        'description' => 'No Of subscribers this newsletter sent to.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => 0,
      ),
      'clicks' => array(
        'description' => 'how many clicks this newsletter/list generated for the website.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'opens' => array(
        'description' => 'how many times this newsletter/list opened by subscriber.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'last_sent' => array(
        'description' => 'The last sent timestamp of this newsletter.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => 0,
      ),
    ),
    'foreign keys' => array(
      'tracked_template' => array(
        'table' => 'newsletter_templates',
        'columns' => array(
          'ntid' => 'ntid',
        ),
      ),
    ),
    'indexes' => array(
      'newsletter_send_id' => array(
        'send_id',
      ),
      'newsletter_last_sent' => array(
        'last_sent',
      ),
    ),
    'primary key' => array(
      'nnid',
    ),
  );
  return $schema;
}