You are here

function simplenews_schema in Simplenews 3.x

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

Implements hook_schema().

File

./simplenews.install, line 17
Install, update and uninstall functions for the simplenews module.

Code

function simplenews_schema() {
  $schema['simplenews_mail_spool'] = [
    'description' => 'Spool for temporary storage of newsletter emails.',
    'fields' => [
      'msid' => [
        'description' => 'The primary identifier for a mail spool record.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ],
      'entity_type' => [
        'description' => 'The entity type of this newsletter issue.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'entity_id' => [
        'description' => 'The entity id of this newsletter issue.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ],
      'newsletter_id' => [
        'description' => 'The {simplenews_newsletter}.id this email belongs to.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ],
      'status' => [
        'description' => 'The sent status of the email (0 = hold, 1 = pending, 2 = done, 3 = in progress, 4 = skipped, 5 = failed).',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
      ],
      'timestamp' => [
        'description' => 'The time status was set or changed.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'data' => [
        'description' => 'A serialized array of name value pairs that define a temporary subscriber.',
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
      ],
      'snid' => [
        'description' => 'Foreign key for subscriber table ({simplenews_subscriber}.id).',
        'type' => 'int',
        'not null' => FALSE,
      ],
    ],
    'primary key' => [
      'msid',
    ],
    'indexes' => [
      'newsletter_id' => [
        'newsletter_id',
      ],
      'status' => [
        'status',
      ],
      'snid_newsletter_id' => [
        'snid',
        'newsletter_id',
      ],
    ],
    'foreign keys' => [
      'newsletter_id' => [
        'table' => 'simplenews_newsletter',
        'columns' => [
          'newsletter_id',
        ],
      ],
      'snid_newsletter_id' => [
        'table' => 'simplenews_subscription',
        'columns' => [
          'snid' => 'snid',
          'newsletter_id' => 'newsletter_id',
        ],
      ],
    ],
  ];
  return $schema;
}