You are here

function feedapi_update_6105 in FeedAPI 6

Adds vid to feedapi table

File

./feedapi.install, line 195
Install file for FeedAPI module.

Code

function feedapi_update_6105() {
  global $db_type;
  $ret = array();
  db_add_field($ret, 'feedapi', 'vid', array(
    'description' => 'The primary identifier for the feed.',
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_drop_primary_key($ret, 'feedapi');
  if ($db_type == 'mysql' || $db_type == 'mysqli') {
    $ret[] = update_sql("UPDATE {feedapi} f, {node} n SET f.vid = n.vid WHERE n.nid = f.nid");
  }
  else {
    $ret[] = update_sql("UPDATE {feedapi} SET vid = n.vid FROM (SELECT vid, nid FROM {node} n) n WHERE n.nid = feedapi.nid");
  }
  $ret[] = update_sql("UPDATE {feedapi} SET vid = nid WHERE vid = 0");
  db_add_primary_key($ret, 'feedapi', array(
    'vid',
    'nid',
  ));
  db_add_index($ret, 'feedapi', 'vid', array(
    'vid',
  ));
  return $ret;
}