function tripal_library_update_7201
2.x tripal_library.install | tripal_library_update_7201() |
Fixes an error with the materialized view installation
File
- tripal_library/
tripal_library.install, line 415 - Installation of the library module
Code
function tripal_library_update_7201() {
// Make sure we have the full API loaded this will help during a
// site upgrade when the tripal_core module is disabled.
module_load_include('module', 'tripal_core', 'tripal_core');
tripal_core_import_api();
// there is a bug in the Tripal v2.0-alpha release that didn't add the
// materialized view schema to the mviews table.
// get the schema for the materialized view from the custom_tables table
// as there is a copy there, but only if the schema is missing from the
// materialized view table
$view_name = 'library_feature_count';
$schema = db_select('tripal_mviews', 'tm')
->fields('tm', array('mv_schema'))
->condition('name', $view_name)
->execute()
->fetchField();
if (!$schema or $schema == 'Array') {
$schema = db_select('tripal_custom_tables', 'tct')
->fields('tct', array('schema'))
->condition('table_name', $view_name)
->execute()
->fetchField();
$schema_str = var_export(unserialize($schema), TRUE);
$schema_str = preg_replace('/=>\s+\n\s+array/', '=> array', $schema_str);
db_update('tripal_mviews')
->fields(array(
'mv_schema' => $schema_str
))
->condition('name', $view_name)
->execute();
}
}