You are here

function system_update_6001 in Drupal 6

Add version id column to {term_node} to allow taxonomy module to use revisions.

Related topics

File

modules/system/system.install, line 1229

Code

function system_update_6001() {
  $ret = array();

  // Add vid to term-node relation.  The schema says it is unsigned.
  db_add_field($ret, 'term_node', 'vid', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_drop_primary_key($ret, 'term_node');
  db_add_primary_key($ret, 'term_node', array(
    'vid',
    'tid',
    'nid',
  ));
  db_add_index($ret, 'term_node', 'vid', array(
    'vid',
  ));
  db_query('UPDATE {term_node} SET vid = (SELECT vid FROM {node} n WHERE {term_node}.nid = n.nid)');
  return $ret;
}