You are here

function metatags_quick_update_7004 in Meta tags quick 7.2

Change primary key to id field and add unique index on path and lang.

File

./metatags_quick.install, line 110
Defines schema for metatags_quick fields

Code

function metatags_quick_update_7004() {

  /*
   * Normally we'd use db_drop_primary_key()/db_add_primary_key(), but MySQL
   * wont let us drop the primary key if it's an autoincrement field. Altering
   * like this, however, works.
   *
   * This will fail on SQLite, as its ALTER TABLE is rather simplified, but as
   * this change is introduced because of SQLites failure to install in the
   * first place, that's irrelevant. PostgreSQL seems to support the same
   * syntax, so it should work.
   */
  if (db_driver() == 'mysql') {
    db_query('ALTER TABLE {metatags_quick_path_based} DROP PRIMARY KEY, ADD PRIMARY KEY (`id`)');
  }
  if (!db_index_exists('metatags_quick_path_based', 'lang_path')) {
    db_add_unique_key('metatags_quick_path_based', 'lang_path', array(
      'lang',
      'path',
    ));
  }
}