You are here

function biblio_update_7300 in Bibliography Module 7.3

Upgrade Biblio schema to 3.x.

File

./biblio.install, line 263
Install file for the biblio module.

Code

function biblio_update_7300() {

  // Rename the old biblio tables.
  $old_biblio_tables = array(
    'biblio',
    'biblio_collection',
    'biblio_collection_type',
    'biblio_contributor',
    'biblio_contributor_type',
    'biblio_contributor_type_data',
    'biblio_duplicates',
    'biblio_field_type',
    'biblio_field_type_data',
    'biblio_fields',
    'biblio_import_cache',
    'biblio_keyword',
    'biblio_keyword_data',
    'biblio_type_maps',
    'biblio_types',
    'biblio_vtabs',
  );
  foreach ($old_biblio_tables as $table) {
    db_rename_table($table, "_{$table}_1x");
  }
  db_rename_table('biblio_contributor_data', 'biblio_contributor');
  $schema = biblio_schema_7300();
  db_add_field('biblio_contributor', 'created', $schema['biblio_contributor']['fields']['created']);
  db_add_field('biblio_contributor', 'changed', $schema['biblio_contributor']['fields']['changed']);
  unset($schema['biblio_contributor']);
  foreach ($schema as $table => $table_schema) {
    db_create_table($table, $table_schema);
  }

  // Enable the new needed modules. We also enable Biblio as we need to rely on
  // it and create Biblio types.
  if (!module_enable(array(
    'biblio',
    'biblio_ui',
    'inline_entity_form',
    'date',
    'entity',
    'entityreference',
    'field_collection',
    'libraries',
  ))) {
    throw new DrupalUpdateException('Inline entity form, Date, Entity reference, Field collection and Libraries modules must be present for Biblio 3.x.');
  }
  _biblio_install_add_biblio_roles();
  biblio_add_publication_types();
  biblio_create_fields_by_bundle();
  return t('Old Biblio tables were renamed and the new tables were created.');
}