function taxonomy_update_7002
Add {vocabulary}.machine_name column.
File
-
modules/
taxonomy/ taxonomy.install, line 291
Code
function taxonomy_update_7002() {
$field = array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'The vocabulary machine name.',
);
db_add_field('taxonomy_vocabulary', 'machine_name', $field);
// Do a direct query here, rather than calling taxonomy_get_vocabularies(),
// in case Taxonomy module is disabled.
$vids = db_query('SELECT vid FROM {taxonomy_vocabulary}')->fetchCol();
foreach ($vids as $vid) {
$machine_name = 'vocabulary_' . $vid;
db_update('taxonomy_vocabulary')->fields(array(
'machine_name' => $machine_name,
))
->condition('vid', $vid)
->execute();
}
// The machine_name unique key can only be added after we ensure the
// machine_name column contains unique values.
db_add_unique_key('taxonomy_vocabulary', 'machine_name', array(
'machine_name',
));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.