function flashnode_update_9 in Flash Node 5.3
Same name and namespace in other branches
- 5.6 flashnode.install \flashnode_update_9()
Add two additional columns in preparation for Drupal 6 Need to add fid and vid Set vid = nid, and set fid based on the entries in {files} In Drupal 6 nid will be dropped, so we need fid as of now!
File
- ./
flashnode.install, line 223
Code
function flashnode_update_9() {
// Add new columns
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {flashnode} ADD vid int NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {flashnode} ADD fid int NOT NULL default '0'");
// Populate columns with data
$ret[] = update_sql("UPDATE {flashnode} fn INNER JOIN {node} n ON fn.nid = n.nid SET fn.vid = n.vid");
$ret[] = update_sql("UPDATE {flashnode} fn INNER JOIN {files} f ON fn.nid = f.nid SET fn.fid = f.fid");
break;
case 'pgsql':
db_add_column($ret, 'flashnode', 'vid', 'int', array(
'default' => 0,
'not null' => TRUE,
));
db_add_column($ret, 'flashnode', 'fid', 'int', array(
'default' => 0,
'not null' => TRUE,
));
// Populate columns with data
$ret[] = update_sql("UPDATE {flashnode} fn SET vid = n.vid FROM {node} n WHERE fn.nid = n.nid");
$ret[] = update_sql("UPDATE {flashnode} fn SET fid = f.fid FROM {files} f WHERE fn.nid = f.nid");
break;
}
return $ret;
}