function og_update_7000 in Organic groups 7
Same name and namespace in other branches
- 7.2 og.install \og_update_7000()
Upgrade from Organic groups 6 to 7.
File
- ./
og.install, line 667 - 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');
// Add serial ID to d6_og* tables so we can keep track of records that were
// processed.
foreach (array(
'd6_og',
'd6_og_ancestry',
'd6_og_uid',
) as $table) {
// Drop the current primary key, as we are adding a serial column.
db_drop_primary_key($table);
db_add_field($table, 'upgrade_id', array(
'description' => 'This a serial ID that keeps track of records that were processed.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
), array(
'primary key' => array(
'upgrade_id',
),
));
}
$schema = og_schema_7000_info();
foreach (array(
'og',
'og_role_permission',
'og_role',
'og_users_roles',
) as $table) {
db_create_table($table, $schema[$table]);
}
// We can't call og_needs_migrate() directly, so just set the variable.
variable_set('og_needs_migrate', TRUE);
return t('Renamed Organic groups 6 tables. Enable Organic groups migrate module to continue the migration of data.');
}
return t('No change needed in Organic groups schema.');
}