You are here

function synonyms_update_7104 in Synonyms 7

Truncating 'entity_type' and 'bundle' columns to 128 length.

File

./synonyms.install, line 318
Install, update, and uninstall functions for the Synonyms module.

Code

function synonyms_update_7104() {
  $table = 'synonyms_settings';
  $indexes = array(
    'unique keys' => array(
      // We build 2 different indexes on the same column set because there are
      // 2 different functions that may query this table and the columns they
      // filter on may vary.
      'behavior_implementation' => array(
        'behavior',
        'entity_type',
        'bundle',
        'provider',
      ),
      'all_enabled' => array(
        'entity_type',
        'bundle',
        'provider',
        'behavior',
      ),
    ),
  );
  $fields = array(
    'entity_type' => array(
      'description' => 'Entity type whose behavior implementation is stored in this row.',
      'type' => 'varchar',
      'length' => 128,
      'not null' => TRUE,
    ),
    'bundle' => array(
      'description' => 'Bundle name whose behavior implementation is stored in this row.',
      'type' => 'varchar',
      'length' => 128,
      'not null' => TRUE,
    ),
  );
  foreach ($fields as $field => $schema) {
    foreach ($indexes['unique keys'] as $index_name => $index_specification) {
      db_drop_unique_key($table, $index_name);
    }
    db_change_field($table, $field, $field, $schema, $indexes);
  }
}