Commit 2b521ca3 authored by Adrian Rossouw's avatar Adrian Rossouw

working provision-migrate command, and also working provision-deploy.

had to make a nasty hack to step around drush internals because site aliases
put stuff in the options context that dont come from the command line options.
parent e59f845c
......@@ -9,7 +9,6 @@ function drush_db_provision_deploy() {
d()->service('db')->import_site_database();
}
function drush_db_provision_deploy_rollback() {
d()->service('db')->destroy_site_database();
}
......
......@@ -7,9 +7,5 @@ function drush_db_provision_migrate_validate() {
// Deletes the old database credentials
function drush_db_post_provision_migrate() {
d()->service('db')->destroy_site_database(
drush_get_option('db_name'),
drush_get_option('db_user'),
drush_get_option('db_passwd')
);
d()->service('db')->destroy_site_database();
}
......@@ -19,8 +19,6 @@
* Make sure we have a valid site being deployd, and that the file being deployd from exists
*/
function drush_provision_drupal_provision_deploy_validate($backup_file = null) {
_provision_drupal_url_required();
$exists = d()->service('file')->exists($backup_file)
->succeed('Deploying site from @path')
->fail('Could not find backup file @path', 'PROVISION_BACKUP_NOT_FOUND')
......@@ -35,9 +33,9 @@ function drush_provision_drupal_provision_deploy_validate($backup_file = null) {
*/
function drush_provision_drupal_pre_provision_deploy($backup_file) {
// the url is likely to have changed in the deployment
$extracted = d()->service('file')->extract(drush_get_option('backup_file'), d()->root . '/sites/' . d()->uri)
$extracted = d()->service('file')->extract($backup_file, d()->root . '/sites/' . d()->uri)
->succeed('Successfully extracted the contents of @path')
->fail('Failed to extract the contents of @path', 'PROVISION_BACKUP_EXTRACTION_FAILED')
->fail('Failed to extract the contents of @path to @target', 'PROVISION_BACKUP_EXTRACTION_FAILED')
->status();
if ($extracted) {
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
......@@ -88,7 +86,7 @@ function drush_provision_drupal_post_provision_deploy() {
_provision_drupal_create_settings_file();
provision_save_site_data();
// call the drush updatedb command.
drush_backend_invoke("updatedb", array('uri' => 'http://' . drush_get_option('uri')));
provision_backend_invoke(d()->name, 'updatedb');
// We should be able to fully load Drupal now.
if (drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL)) {
drush_include_engine('drupal', 'deploy');
......
......@@ -44,7 +44,7 @@ function drush_provision_drupal_pre_provision_migrate($platform = null) {
* Remove the extracted site directory
* Restore the vhost conf per the original platform
*/
function drush_provision_drupal_pre_provision_migrate_rollback($platform = null) {
function drush_provision_drupal_pre_provision_migrate_rollback($platform) {
// Set site_offline to false and regenerate the config
drush_log(dt("Bringing site out of maintenance"));
drush_set_option('site_offline', 0);
......@@ -60,12 +60,11 @@ function drush_provision_drupal_pre_provision_migrate_rollback($platform = null)
* Switch the migrate directories around now that we have the new db installed
*/
function drush_provision_drupal_provision_migrate($platform) {
drush_backend_invoke('provision-deploy', array(drush_get_option('backup_file'), 'root' => $platform,
'web_host' => drush_get_option('web_host'),
'db_host' => drush_get_option('db_host'), 'profile' => drush_get_option('profile')));
drush_set_option('old_platform', d()->platform->name);
drush_backend_invoke_args('provision-save', array(d()->name), array('platform' => $platform, 'root' => null, 'uri' => null));
provision_backend_invoke(d()->name, 'provision-deploy', array(drush_get_option('backup_file')));
}
/**
* Delete the old site directory and recreate the settings file
*/
......
......@@ -13,12 +13,24 @@ function & d($name = NULL, $root_object = FALSE) {
static $instances = null;
static $default_instance = '@self';
if ($name == 'all') {
return $instances;
}
if (is_null($name)) {
return $instances[$default_instance];
}
else {
if ($root_object) {
$default_instance = $name;
if ($name != '@self') {
// This is an unfortunate workaround to the drush sitealias functionality, which pollutes
// the options namespace with the alias sourced settings.
drush_set_option('root', drush_get_option('root', null, 'options'), 'process');
drush_set_option('uri', drush_get_option('uri', null, 'options'), 'process');
drush_unset_option('root', 'options');
drush_unset_option('uri', 'options');
}
}
if (isset($instances[$name])) {
......
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