You are here

function flag_update_6202 in Flag 7.3

Same name and namespace in other branches
  1. 6.2 flag.install \flag_update_6202()
  2. 7.2 flag.install \flag_update_6202()

Add the sid column and unique index on the flag_content table.

File

./flag.install, line 317
Flag module install/schema/update hooks.

Code

function flag_update_6202() {

  // Drop the keys affected by the addition of the SID column.
  db_drop_unique_key('flag_content', 'fid_content_id_uid');
  db_drop_index('flag_content', 'content_type_uid');

  // Add the column.
  db_add_field('flag_content', 'sid', array(
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));

  // Re-add the removed keys.
  db_add_unique_key('flag_content', 'fid_content_id_uid_sid', array(
    'fid',
    'content_id',
    'uid',
    'sid',
  ));
  db_add_index('flag_content', 'content_type_uid_sid', array(
    'content_type',
    'uid',
    'sid',
  ));
}