You are here

function values_update_7100 in Values 7

Rename values_list table to values_sets. Add title column. Copy descriptions to new title column

File

./values.install, line 108
Install file for Values module.

Code

function values_update_7100(&$sandbox) {
  db_rename_table('values_list', 'values_sets');
  $spec = array(
    'description' => 'Title of the value set',
    'type' => 'varchar',
    'length' => 255,
  );
  db_add_field('values_sets', 'title', $spec);

  // Move the title column (on mysql only - pgsql doesn't have a way to do this
  // without creating new columns in a specific order and deleting the old ones)
  if (Database::getConnection()
    ->driver() == 'mysql') {
    db_query("ALTER table {values_sets} MODIFY COLUMN title varchar(255) AFTER name");
  }

  // Update the new title field with whatever was in description
  db_query("UPDATE {values_sets} SET title = description");
  return;
}