You are here

function flag_update_7204 in Flag 7.2

Increase the size of the database columns that refer to entity types or bundles.

File

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

Code

function flag_update_7204() {

  // Change the 'content_type' column on the {flags} table.
  db_change_field('flags', 'content_type', 'content_type', array(
    'description' => 'The flag type, such as one of "node", "comment", or "user".',
    'type' => 'varchar',
    'length' => '128',
    'not null' => TRUE,
    'default' => '',
  ));

  // Drop the indexes that use the 'content_type' column of the {flag_contents} table.
  db_drop_index('flag_content', 'content_type_content_id_uid_sid');
  db_drop_index('flag_content', 'content_type_uid_sid');

  // Change the 'content_type' column on the {flag_content} table.
  db_change_field('flag_content', 'content_type', 'content_type', array(
    'description' => 'The flag type, one of "node", "comment", "user".',
    'type' => 'varchar',
    'length' => '128',
    'not null' => TRUE,
    'default' => '',
  ));

  // Recreate the indexes which utilize the 'content_type' of the {flag_content} table
  db_add_index('flag_content', 'content_type_content_id_uid_sid', array(
    'content_type',
    'content_id',
    'uid',
    'sid',
  ));
  db_add_index('flag_content', 'content_type_uid_sid', array(
    'content_type',
    'uid',
    'sid',
  ));

  // Change the 'type' column on the {flag_types} table.
  db_change_field('flag_types', 'type', 'type', array(
    'description' => 'The types (usually from {node_type}) that can be flagged by this fid.',
    'type' => 'varchar',
    'length' => '128',
    'not null' => TRUE,
    'default' => '',
  ));

  // Drop the indexes that use the 'content_type' column of the {flag_counts} table.
  db_drop_index('flag_counts', 'fid_content_type');
  db_drop_index('flag_counts', 'content_type_content_id');

  // Change the 'content_type' column on the {flag_counts} table.
  db_change_field('flag_counts', 'content_type', 'content_type', array(
    'description' => 'The flag type, usually one of "node", "comment", "user".',
    'type' => 'varchar',
    'length' => '128',
    'not null' => TRUE,
    'default' => '',
  ));

  // Recreate the indexes which utilize the 'content_type' of the {flag_counts} table.
  db_add_index('flag_counts', 'fid_content_type', array(
    'fid',
    'content_type',
  ));
  db_add_index('flag_counts', 'content_type_content_id', array(
    'content_type',
    'content_id',
  ));
}