You are here

function search_api_update_7110 in Search API 7

Rename the "entity_type" field to "item_type" in the {search_api_index} table.

File

./search_api.install, line 781
Install, update and uninstall functions for the Search API module.

Code

function search_api_update_7110() {
  $table = 'search_api_index';

  // This index isn't used anymore.
  db_drop_index($table, 'entity_type');

  // Rename the "item_type" field (and change the description).
  $item_type = array(
    'description' => 'The type of items stored in this index.',
    'type' => 'varchar',
    'length' => 50,
    'not null' => TRUE,
  );

  // Also add the new "item_type" index, while we're at it.
  $keys_new['indexes']['item_type'] = array(
    'item_type',
  );
  db_change_field($table, 'entity_type', 'item_type', $item_type, $keys_new);

  // Mark all indexes in code as "OVERRIDDEN".
  db_update($table)
    ->fields(array(
    'status' => 0x3,
  ))
    ->condition('status', 0x2)
    ->execute();

  // Clear entity info caches.
  cache_clear_all('*', 'cache', TRUE);
}