You are here

function simplenews_schema in Simplenews 6.2

Same name and namespace in other branches
  1. 8.2 simplenews.install \simplenews_schema()
  2. 8 simplenews.install \simplenews_schema()
  3. 6 simplenews.install \simplenews_schema()
  4. 7.2 simplenews.install \simplenews_schema()
  5. 7 simplenews.install \simplenews_schema()
  6. 3.x simplenews.install \simplenews_schema()

Implementation of hook_schema().

File

./simplenews.install, line 31
Simplenews installation.

Code

function simplenews_schema() {
  $schema['simplenews_subscriptions'] = array(
    'description' => 'Subscribers to {simplenews_newsletters}.',
    'fields' => array(
      'snid' => array(
        'description' => 'Primary key: Unique subscription ID.',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'activated' => array(
        'description' => 'Boolean indicating the status of the subscription.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'mail' => array(
        'description' => 'The subscription email address.',
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'uid' => array(
        'description' => 'The {users}.uid that has the same email address.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'language' => array(
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Anonymous subscriber preferred language. Empty for authenticated users.',
      ),
      'timestamp' => array(
        'description' => 'UNIX timestamp of when the user first subscribed to a newsletter.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'mail' => array(
        'mail',
      ),
      'uid' => array(
        'uid',
      ),
    ),
    'primary key' => array(
      'snid',
    ),
  );
  $schema['simplenews_newsletters'] = array(
    'description' => 'Simplenews newsletter data.',
    'fields' => array(
      'nid' => array(
        'description' => '{node} that is used as newsletter.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'vid' => array(
        'description' => 'The {node}.vid that identifies the version used as newsletter.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'tid' => array(
        'description' => 'The {term_data}.tid (= newsletter series) this issue belongs to.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      's_status' => array(
        'description' => 'Sent status of the newsletter issue (0 = not send; 1 = pending; 2 = send). ',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      's_format' => array(
        'description' => 'Format of the newsletter (plain or html).',
        'type' => 'varchar',
        'length' => 8,
        'not null' => TRUE,
        'default' => '',
      ),
      'priority' => array(
        'description' => 'Email priority according to RFC 2156 and RFC 5231 (0 = none; 1 = highest; 2 = high; 3 = normal; 4 = low; 5 = lowest).',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'receipt' => array(
        'description' => 'Boolean indicating request for email receipt confirmation according to RFC 2822.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'sent_subscriber_count' => array(
        'description' => 'The count of subscribers to the newsletter when it was sent.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'nid',
    ),
  );
  $schema['simplenews_snid_tid'] = array(
    'description' => 'Newsletter series subscription data.',
    'fields' => array(
      'snid' => array(
        'description' => 'The {simplenews_subscriptions}.snid who is subscribed.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'tid' => array(
        'description' => 'The newsletter series ({term_data}.tid) the subscriber is subscribed to.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => 'A flag indicating whether the user is subscribed (1) or unsubscribed (0).',
        'type' => 'int',
        'size' => 'small',
        'not null' => TRUE,
        'default' => 1,
      ),
      'timestamp' => array(
        'description' => 'UNIX timestamp of when the user is (un)subscribed.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'source' => array(
        'description' => 'The source via which the user is (un)subscription.',
        'type' => 'varchar',
        'length' => 24,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'snid',
      'tid',
    ),
  );
  $schema['simplenews_mail_spool'] = array(
    'description' => 'Spool for temporary storage of newsletter emails.',
    'fields' => array(
      'msid' => array(
        'description' => 'The primary identifier for a mail spool record.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'snid' => array(
        'description' => 'Foreign key for subscriber table ({simplenews_subscriptions}.snid)',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'mail' => array(
        'description' => 'The formatted email address of mail message recipient.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'nid' => array(
        'description' => 'The {node}.nid of this newsletter.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'vid' => array(
        'description' => 'The {node}.vid of this newsletter.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'tid' => array(
        'description' => 'The {term_data}.tid this newsletter issue belongs to.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => 'The sent status of the email (0 = hold, 1 = pending, 2 = done).',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
      ),
      'error' => array(
        'description' => 'A boolean indicating whether an error occurred while sending the email.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'timestamp' => array(
        'description' => 'The time status was set or changed.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'msid',
    ),
    'indexes' => array(
      'tid' => array(
        'tid',
      ),
      'status' => array(
        'status',
      ),
    ),
  );
  return $schema;
}