function apachesolr_update_6302 in Apache Solr Search 6.3
This function cleans up the old apachesolr tables. There is no magic upgrade pat. The old facet and MLT blocks will be gone
File
- ./
apachesolr.install, line 318 - Install and related hooks for apachesolr_search.
Code
function apachesolr_update_6302() {
$ret = array();
// check if old tables are present and remove them
if (db_table_exists('apachesolr_search_node')) {
drupal_load('module', 'content');
module_load_include('inc', 'apachesolr', 'apachesolr_search.admin');
module_load_include('module', 'apachesolr', 'apachesolr');
module_load_include('inc', 'apachesolr', 'apachesolr.index');
// Remove the old tracking table
$ret[] = update_sql('DROP TABLE {apachesolr_search_node}');
// Remove cache table, will be freshly installed
$ret[] = update_sql('DROP TABLE {cache_apachesolr}');
// Delete all old facet blocks
$ret[] = update_sql("DELETE FROM {blocks} WHERE 'module' = 'apachesolr'");
// Delete old variables
variable_del('apachesolr_enabled_facets');
variable_del('apachesolr_facet_missing');
variable_del('apachesolr_facet_query_initial_limits');
variable_del('apachesolr_facet_query_limits');
variable_del('apachesolr_index_last');
variable_del('apachesolr_index_updated');
variable_del('apachesolr_last_optimize');
variable_del('apachesolr_host');
variable_del('apachesolr_path');
variable_del('apachesolr_port');
variable_del('apachesolr_set_nodeapi_messages');
variable_del('apachesolr_site_hash');
// Create tables.
drupal_install_schema('apachesolr');
// Create one MLT block.
apachesolr_search_mlt_save_block(array(
'name' => t('More like this'),
));
// Insert our default environment
$ret[] = db_query("INSERT INTO {apachesolr_environment} (env_id, name, url, service_class)\n VALUES ('%s', '%s', '%s', '%s')", array(
'solr',
'localhost server',
'http://localhost:8983/solr',
'',
));
// Initialize the entities to index. We enable all node types by default
$env_id = apachesolr_default_environment();
$bundles = content_types();
apachesolr_index_set_bundles($env_id, 'node', array_keys($bundles));
apachesolr_enable();
}
return $ret;
}