function dbtng_migrator_settings_validate in DBTNG Migrator 7
Validation handler for form dbtng_migrator_settings.
File
- ./
dbtng_migrator.admin.inc, line 194
Code
function dbtng_migrator_settings_validate($form, $form_state) {
if ($form_state['values']['migrate_destination'] == $form_state['values']['migrate_origin']) {
form_set_error('migrate_destination', t('Migration origin cannot be the same as the destination.'));
return;
}
$origin = $form_state['values']['migrate_origin'];
$dest = $form_state['values']['migrate_destination'];
// Connect to the origin and generate a list of tables in the database.
db_set_active($origin);
include_once DRUPAL_ROOT . '/includes/install.inc';
// Load install files to expose hook_schema_alter hooks.
drupal_load_updates();
$modules = module_list(TRUE);
$tables = array();
foreach ($modules as $module) {
$schema = drupal_get_schema_unprocessed($module);
_drupal_schema_initialize($schema, $module, TRUE);
// Some modules won't actually have a schema.
if (!is_array($schema)) {
continue;
}
foreach ($schema as $table => $info) {
$tables[] = $table;
}
}
// Check that those tables don't already exists in the destination.
db_set_active($dest);
foreach ($tables as $table) {
if (db_table_exists($table)) {
form_set_error('migrate_destination', t('%table already exists in destination database. DBTNG Migrator will not override existing data', array(
'%table' => $table,
)));
}
}
db_set_active('default');
}