function nodequeue_update_6006 in Nodequeue 6.2
Implementation of hook_update_N Renaming indices so that they're consistent with what Schema module would expect
File
- ./
nodequeue.install, line 476 - Install, update and uninstall functions for the nodequeue module.
Code
function nodequeue_update_6006() {
$ret = array();
// Get all indices from {nodequeue_nodes}.
$result = db_query("SHOW INDEX FROM {nodequeue_nodes}");
while ($index = db_fetch_array($result)) {
$nn_indices[$index['Key_name']] = $index;
}
// Check if one the indices exists before trying to drop them.
if (isset($nn_indices['nodequeue_nodes_sqid_idx'])) {
// Delete existing indexes
$del_indices = array(
'nodequeue_roles' => array(
'qid',
'rid',
),
'nodequeue_types' => array(
'qid',
'type',
),
'nodequeue_subqueue' => array(
'qid',
'reference',
'title',
),
'nodequeue_nodes' => array(
'sqid',
'qid_nid',
),
);
foreach ($del_indices as $table => $indices) {
foreach ($indices as $k => $index) {
db_drop_index($ret, $table, $table . "_" . $index . "_idx");
}
}
// Naming convention incorrect for this one
db_drop_index($ret, "nodequeue_nodes", "nodequeue_subqueue_nid_idx");
}
// Check if the new indices weren't already created.
if (!isset($nn_indices['sqid'])) {
// Create new indexes
$add_indexes = array(
'nodequeue_roles' => array(
'qid' => array(
'qid',
),
'rid' => array(
'rid',
),
),
'nodequeue_types' => array(
'qid' => array(
'qid',
),
'type' => array(
'type',
),
),
'nodequeue_subqueue' => array(
'qid' => array(
'qid',
),
'reference' => array(
'reference',
),
'title' => array(
'title',
),
),
'nodequeue_nodes' => array(
'sqid' => array(
'sqid',
'position',
),
'qid_nid' => array(
'qid',
'nid',
),
'nid' => array(
'nid',
),
),
);
foreach ($add_indexes as $table => $indices) {
foreach ($indices as $name => $columns) {
db_add_index($ret, $table, $name, $columns);
}
}
}
return $ret;
}