function taxonomy_update_8006

Change {taxonomy_term_data}.vid into a string holding the vocabulary machine name.

File

drupal/core/modules/taxonomy/taxonomy.install, line 317
Install, update and uninstall functions for the taxonomy module.

Code

function taxonomy_update_8006() {
  db_drop_index('taxonomy_term_data', 'taxonomy_tree');
  db_drop_index('taxonomy_term_data', 'vid_name');
  db_change_field('taxonomy_term_data', 'vid', 'vid', array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
    'description' => 'The ID of the vocabulary to which the term is assigned.',
  ));
  db_add_index('taxonomy_term_data', 'taxonomy_tree', array(
    array(
      'vid',
      64,
    ),
    'weight',
    'name',
  ));
  db_add_index('taxonomy_term_data', 'vid_name', array(
    array(
      'vid',
      64,
    ),
    'name',
  ));
  $map = db_query('SELECT vid, machine_name FROM {taxonomy_vocabulary}')
    ->fetchAllKeyed();
  foreach ($map as $vid => $machine_name) {
    db_update('taxonomy_term_data')
      ->condition('vid', $vid)
      ->fields(array(
      'vid' => $machine_name,
    ))
      ->execute();
  }
}