You are here

function og_update_7000 in Organic groups 7.2

Same name and namespace in other branches
  1. 7 og.install \og_update_7000()

Upgrade from Organic groups 6 to 7.

File

./og.install, line 868
Install, update, and uninstall functions for the Organic groups module.

Code

function og_update_7000(&$sandbox) {
  if (db_field_exists('og', 'nid') && !db_table_exists('d6_og')) {

    // Rename the old table, so we can populate the new {og} table using API
    // functions, that assume the new DB structure.
    db_rename_table('og', 'd6_og');
    db_rename_table('og_ancestry', 'd6_og_ancestry');
    db_rename_table('og_uid', 'd6_og_uid');

    // The tables that will need to be processed.
    $tables = array(
      'd6_og',
      'd6_og_ancestry',
      'd6_og_uid',
    );

    // If OG user roles module was installed in the past, make a copy of
    // its table.
    if (db_table_exists('og_users_roles')) {
      db_rename_table('og_users_roles', 'd6_og_users_roles');
      $tables[] = 'd6_og_users_roles';
    }
    $schema = og_schema_7000_info();
    foreach (array(
      'og',
      'og_role_permission',
      'og_role',
      'og_users_roles',
    ) as $table) {
      db_create_table($table, $schema[$table]);
    }

    // Temporary variable to indicate we need to add OG related fields.
    variable_set('og_7000_add_field', TRUE);
    variable_set('og_ui_7000_add_field', TRUE);
    return t('Renamed Organic groups 6 tables. Enable "Migrate-UI" module to continue the migration of data. Once migration is done you may disable "Migrate" module');
  }
  return t('No change needed in Organic groups schema.');
}