You are here

function simplenews_update_6001 in Simplenews 6

Same name and namespace in other branches
  1. 6.2 simplenews.install \simplenews_update_6001()

Addition of simplenews_mail_cache table. Related to this new table: the removal of simplenews_subscriptions is_send status. Correction of simplenews_newsletters priority field type.

File

./simplenews.install, line 369
Simplenews installation.

Code

function simplenews_update_6001() {
  $schema['simplenews_mail_cache'] = array(
    'description' => '',
    'fields' => array(
      'mcid' => array(
        'description' => 'The primary identifier for a mail cache record.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'tid' => array(
        'description' => 'The {term_data}.tid this newsletter issue belongs to.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'subject' => array(
        'description' => 'The subject of this mail message.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'mail' => array(
        'description' => 'The formatted email address of mail message receipient.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'status' => array(
        'description' => 'The sent status of the email (0 = hold, 1 = pending, 2 = send).',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
      ),
      'timestamp' => array(
        'description' => 'The time status was set or changed.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'message' => array(
        'description' => 'The mail message array.',
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
      ),
    ),
    'primary key' => array(
      'mcid',
    ),
    'indexes' => array(
      'tid' => array(
        'tid',
      ),
      'status' => array(
        'status',
      ),
    ),
  );
  $ret = array();

  // New table to buffer mail messages during sending
  db_create_table($ret, 'simplenews_mail_cache', $schema['simplenews_mail_cache']);

  // Remove is_send field. No longer required by the introduction of simplenews_mail_cache table
  db_drop_field($ret, 'simplenews_subscriptions', 'is_send');

  // Convert newsletter priority: change field type string back to int
  db_change_field($ret, 'simplenews_newsletters', 'priority', 'priority', array(
    'type' => 'int',
    'size' => 'tiny',
    'not null' => TRUE,
    'default' => 0,
  ));
  return $ret;
}