Commit 80570f56 authored by Adrian Rossouw's avatar Adrian Rossouw

Migrating sites between database servers is now possible.

parent 3693651e
......@@ -13,6 +13,11 @@ function drush_hosting_migrate_pre_hosting_task($task) {
$task->args[3] = '@' . $task->task_args['new_uri'];
}
if ($site->db_server != $task->task_args['new_db_server']) {
$task->options['new_db_server'] = hosting_context_name($task->task_args['new_db_server']);
}
$profile_instance = _hosting_migrate_get_target_profile_name($task);
if (sizeof($profile_instance)) {
$task->options['profile'] = $profile_instance->short_name;
......@@ -55,6 +60,10 @@ function hosting_migrate_post_hosting_migrate_task($task, $data) {
hosting_context_register($site->nid, $task->task_args['new_uri']);
}
if ($site->db_server != $task->task_args['new_db_server']) {
$site->db_server = $task->task_args['new_db_server'];
}
$profile = hosting_package_instance_load(array(
'rid' => $target,
'short_name' => $data['context']['profile']
......
......@@ -80,6 +80,12 @@ function hosting_task_migrate_form_validate($form, &$form_state) {
}
if ($form_state['values']['parameters']['new_db_server'] != $site->db_server) {
$migrate_possible = TRUE;
}
if (!$migrate_possible) {
form_set_error('parameters][target_platform', t("To migrate a site you need to modify at least one of the following fields: Domain name, Platform or Database server"));
}
......@@ -104,10 +110,26 @@ function hosting_task_migrate_form($node) {
$form['new_uri'] = array (
'#title' => t('Domain name'),
'#type' => 'textfield',
'#required' => TRUE,
'#weight' => '-1',
'#default_value' => $node->title
);
$db_servers = hosting_get_servers('db');
if (sizeof($db_servers) > 1) {
$form['new_db_server'] = array(
'#type' => 'radios',
'#title' => t('Database server'),
'#required' => TRUE,
'#description' => t('The database server the site will use to host it\'s content.'),
'#options' => $db_servers,
'#default_value' => $node->db_server,
);
}
else {
$form['new_db_server'] = array('#type' => 'hidden', '#value' => $node->db_server);
}
drupal_add_js(drupal_get_path('module','hosting_migrate') . '/hosting_migrate.js');
$packages = array();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment