You are here

function sheetnode_update_6003 in Sheetnode 6

Implementation of hook_update_N().

File

./sheetnode.install, line 224

Code

function sheetnode_update_6003(&$sandbox) {
  $ret = array();
  $schema = sheetnode_schema_6003();
  db_add_field($ret, 'sheetnode', 'vid', $schema['sheetnode']['fields']['vid']);

  // set the vid of all existing sheetnode rows to the latest node_revisions.vid.
  db_query('UPDATE {sheetnode} SET {sheetnode}.vid=(SELECT MAX(vid) FROM {node_revisions} WHERE {node_revisions}.nid={sheetnode}.nid GROUP BY {sheetnode}.nid)');
  db_drop_primary_key($ret, 'sheetnode');
  db_add_primary_key($ret, 'sheetnode', array(
    'vid',
  ));
  db_add_index($ret, 'sheetnode', 'nid', array(
    'nid',
  ));
  return $ret;
}