function hosting_task_update_6006 in Hosting 6.2
Same name and namespace in other branches
- 7.4 task/hosting_task.install \hosting_task_update_6006()
- 7.3 task/hosting_task.install \hosting_task_update_6006()
Add nid field to hosting_task_log and remove orphaned log entries.
File
- task/
hosting_task.install, line 253
Code
function hosting_task_update_6006() {
$ret = array();
// Add nid field.
$field = array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
);
// Add some useful indexes.
$indexes = array(
'indexes' => array(
'vid_lid' => array(
'vid',
'lid',
),
'nid' => array(
'nid',
),
),
);
db_add_field($ret, 'hosting_task_log', 'nid', $field, $indexes);
// Populate nid field.
$query = "SELECT nid, vid FROM {hosting_task}";
$result = db_query($query);
while ($task = db_fetch_object($result)) {
$query = "UPDATE {hosting_task_log} SET nid = %d WHERE vid = %d";
db_query($query, $task->nid, $task->vid);
}
// Remove orphaned logs, which will have nid == 0 now.
$query = "DELETE FROM {hosting_task_log} WHERE nid = %d";
db_query($query, 0);
return $ret;
}