function search_api_page_update_7101 in Search API Pages 7
Make {search_api_page}.index_id the index' machine name.
File
- ./
search_api_page.install, line 104 - Install, update and uninstall functions for the Search pages module.
Code
function search_api_page_update_7101() {
// Update of search_api_page:
db_drop_index('search_api_page', 'index_id');
$spec = array(
'description' => 'The {search_api_index}.machine_name this page will search on.',
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
);
db_change_field('search_api_page', 'index_id', 'index_id', $spec);
db_add_index('search_api_page', 'index_id', array(
'index_id',
));
foreach (db_query('SELECT id, machine_name FROM {search_api_index}') as $index) {
// We explicitly forbid numeric machine names, therefore we don't have to worry about conflicts here.
db_update('search_api_page')
->fields(array(
'index_id' => $index->machine_name,
))
->condition('index_id', $index->id)
->execute();
}
}