You are here

function subscriptions_update_6101 in Subscriptions 6

Same name and namespace in other branches
  1. 7 subscriptions.install \subscriptions_update_6101()

Database update function 6101: Add the {subscriptions_last_sent} table.

File

./subscriptions.install, line 403
Subscriptions module installation.

Code

function subscriptions_update_6101() {
  $ret = array();
  $schema['subscriptions_last_sent'] = array(
    'fields' => array(
      'uid' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
      'send_interval' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
      'last_sent' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'uid',
      'send_interval',
    ),
  );
  db_create_table($ret, 'subscriptions_last_sent', $schema['subscriptions_last_sent']);
  db_add_index($ret, 'subscriptions_queue', 'uid', array(
    'uid',
  ));
  include_once drupal_get_path('module', 'subscriptions') . '/subscriptions.admin.inc';
  foreach (_subscriptions_send_intervals() as $send_interval => $text) {
    db_query("INSERT INTO {subscriptions_last_sent} (uid, send_interval, last_sent) SELECT uid, %d, last_sent FROM {subscriptions_user} WHERE uid > 0", $send_interval);
  }
  return $ret;
}