function subscriptions_update_6101 in Subscriptions 7
Same name and namespace in other branches
- 6 subscriptions.install \subscriptions_update_6101()
Database update function 6101: Add the {subscriptions_last_sent} table.
File
- ./
subscriptions.install, line 193 - Subscriptions module installation.
Code
function subscriptions_update_6101() {
$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('subscriptions_last_sent', $schema['subscriptions_last_sent']);
db_add_index('subscriptions_queue', 'uid', array(
'uid',
));
_subscriptions_module_load_include('subscriptions', 'admin.inc');
foreach (_subscriptions_send_intervals() as $send_interval => $text) {
$select = db_select('subscriptions_user', 'su');
$select
->addField('su', 'uid');
$select
->addExpression($send_interval);
$select
->addField('su', 'last_sent');
$select
->condition('su.uid', 0, '>');
db_insert('subscriptions_last_sent')
->from($select)
->execute();
}
}