function smartqueue_update_6003 in Nodequeue 7.3
Same name and namespace in other branches
- 6.2 smartqueue.install \smartqueue_update_6003()
- 7.2 modules/smartqueue/smartqueue.install \smartqueue_update_6003()
Implements hook_update_N().
Adds the smartqueue table.
File
- ./
smartqueue.install, line 38 - Install, update and uninstall functions for the smartqueue module.
Code
function smartqueue_update_6003() {
// Don't use hook_schema for database updates per http://drupal.org/node/150220.
// It's possible that users who installed the 2.7 or 2.8 versions of
// smartqueue will already have this table.
if (!db_table_exists('smartqueue')) {
$schema = array(
'description' => 'Table for smartqueues, storing global information for each queue.',
'fields' => array(
'qid' => array(
'description' => 'The primary identifier for a queue.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'use_parents' => array(
'description' => "Whether a queue is to use the terms' parents when displaying the queue selection.",
'type' => 'int',
'size' => 'tiny',
'default' => 0,
),
),
'primary key' => array(
'qid',
),
);
db_create_table('smartqueue', $schema);
}
$result = db_query('SELECT q.qid FROM {nodequeue_queue} q LEFT JOIN {smartqueue} s ON q.qid = s.qid WHERE s.qid IS NULL');
foreach ($result as $queue) {
db_insert('smartqueue')
->fields(array(
'qid' => $queue->qid,
))
->execute();
}
}