function simplenews_schema in Simplenews 7.2
Same name and namespace in other branches
- 8.2 simplenews.install \simplenews_schema()
- 8 simplenews.install \simplenews_schema()
- 6.2 simplenews.install \simplenews_schema()
- 6 simplenews.install \simplenews_schema()
- 7 simplenews.install \simplenews_schema()
- 3.x simplenews.install \simplenews_schema()
Implements hook_schema().
File
- ./
simplenews.install, line 11 - Install, update and uninstall functions for the simplenews module
Code
function simplenews_schema() {
$schema['simplenews_newsletter'] = array(
'description' => 'Simplenews newsletter categories.',
'fields' => array(
'newsletter_id' => array(
'description' => '...',
'type' => 'serial',
'not null' => TRUE,
),
'name' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'The newsletter name.',
'translatable' => TRUE,
),
'description' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'description' => 'A description of the newsletter.',
'translatable' => TRUE,
),
'format' => array(
'type' => 'varchar',
'length' => 8,
'not null' => TRUE,
'default' => '',
'description' => 'Format of the newsletter email (plain, html).',
),
'priority' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'Email priority according to RFC 2156 and RFC 5231 (0 = none; 1 = highest; 2 = high; 3 = normal; 4 = low; 5 = lowest).',
),
'receipt' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'Boolean indicating request for email receipt confirmation according to RFC 2822.',
),
'from_name' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'Sender name for newsletter emails.',
),
'email_subject' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Subject of newsletter email. May contain tokens.',
),
'from_address' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
'description' => 'Sender address for newsletter emails',
),
'hyperlinks' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
'description' => 'Flag indicating type of hyperlink conversion (1 = hyperlinks are in-line; 0 = hyperlinks are placed at email bottom).',
),
'new_account' => array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
'description' => 'How to treat subscription at account creation (none = None; on = Default on; off = Default off; silent = Invisible subscription).',
),
'opt_inout' => array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
'description' => 'How to treat subscription confirmation (hidden = Newsletter is hidden from the user; single = Single opt-in; double = Double opt-in).',
),
'block' => array(
'description' => 'For this category a subscription block is available.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The weight of this newsletter in relation to other newsletters.',
),
),
'primary key' => array(
'newsletter_id',
),
);
$schema['simplenews_subscriber'] = array(
'description' => 'Newsletter subscribers. Many-to-many relation via {simplenews_subscription}',
'fields' => array(
'snid' => array(
'description' => 'Primary key: Unique subscriber 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 subscriber's 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' => 'Subscriber preferred language.',
),
'changes' => array(
'description' => 'Contains the requested subscription changes',
'type' => 'text',
'serialize' => TRUE,
),
'created' => array(
'description' => 'UNIX timestamp of when the subscription record was added.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'snid',
),
'indexes' => array(
'mail' => array(
'mail',
),
'uid' => array(
'uid',
),
),
'foreign keys' => array(
'uid' => array(
'table' => 'users',
'columns' => array(
'uid' => 'uid',
),
),
),
);
$schema['simplenews_subscription'] = array(
'description' => 'Newsletter subscription data. Which subscriber is subscribed to which mailing list.',
'fields' => array(
'snid' => array(
'description' => 'The {simplenews_subscriber}.snid who is subscribed.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'newsletter_id' => array(
'description' => 'The newsletter ({simplenews_newsletter}.newsletter_id) 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' => 'tiny',
'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',
'newsletter_id',
),
'foreign keys' => array(
'snid' => array(
'table' => 'simplenews_subscriber',
'columns' => array(
'snid' => 'snid',
),
),
'newsletter' => array(
'table' => 'simplenews_newsletter',
'columns' => array(
'newsletter_id' => 'newsletter_id',
),
),
),
);
$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,
),
'mail' => array(
'description' => 'The formatted email address of mail message recipient.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'entity_type' => array(
'description' => 'The entity type of this newsletter issue.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'entity_id' => array(
'description' => 'The entity id of this newsletter issue.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'newsletter_id' => array(
'description' => 'The {simplenews_newsletter}.newsletter_id this 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 occured 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,
),
'data' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array of name value pairs that are related to the email address.',
),
'snid' => array(
'description' => 'Foreign key for subscriber table ({simplenews_subscriptions}.snid)',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'msid',
),
'indexes' => array(
'newsletter_id' => array(
'newsletter_id',
),
'status' => array(
'status',
),
'snid_newsletter_id' => array(
'snid',
'newsletter_id',
),
),
'foreign keys' => array(
'newsletter_id' => array(
'table' => 'simplenews_newsletter',
'columns' => array(
'newsletter_id',
),
),
'snid_newsletter_id' => array(
'table' => 'simplenews_subscription',
'columns' => array(
'snid' => 'snid',
'newsletter_id' => 'newsletter_id',
),
),
),
);
return $schema;
}