You are here

function flag_update_6202 in Flag 6.2

Same name and namespace in other branches
  1. 7.3 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 574
Flag module install/schema/update hooks.

Code

function flag_update_6202() {
  $ret = array();

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

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

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