Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions src/Robo/Plugin/Commands/DeployExportConfigCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Fire\Robo\Plugin\Commands;

use Robo\Robo;
use Robo\Symfony\ConsoleIO;
use Fire\Robo\Plugin\Commands\FireCommandBase;

/**
* Provides as Command that Exports the config from the Selected remote env.
*/
class DeployExportConfigCommand extends FireCommandBase {

/**
* Exports the config from the selected remote enviroment.
*
* Usage Example: fire deploy:export-remote-config
*
* @command deploy:export-remote-config
* @aliases dex
*
*/
public function exportRemoteConfig(ConsoleIO $io) {
$remotePlatform = Robo::config()->get('remote_platform');
$remoteSiteName = Robo::config()->get('remote_sitename');
$defaultCanonicalEnv = Robo::config()->get('remote_canonical_env');

$tasks = $this->collectionBuilder($io);
$confirmation = $io->confirm('You are about to get the lastest Database from a ' . $remotePlatform . ' envoriment and override your local env with, Do you want to continue?');
if ($confirmation) {
$remoteEnv = $io->ask("From which enviroment would like to donwload the Database Copy?", $defaultCanonicalEnv);
if ($remotePlatform == 'pantheon') {
$tasks->addTask($this->taskExec('terminus backup:create ' . $remoteSiteName . '.' . $remoteEnv . ' --element=db'));
}
if ($remotePlatform == 'acquia') {
// @todo get the right database name ask to user or configure from fire.yml.
// Or automatically get it from acquia ?
$acquiaDb = 'my_db';
//acli api:environments:database-backup-create <environmentId> <databaseName>
// https://docs.acquia.com/acquia-cloud-platform/add-ons/acquia-cli/commands/api:environments:database-backup-create
$tasks->addTask($this->task->taskExec('acli api:environments:database-backup-create ' . $remoteSiteName . '.' . $remoteEnv . ' ' . $acquiaDb));
}
$tasks->addTask($this->taskExec('fire local:get-db'));
$tasks->addTask($this->taskExec('fire local:import-db'));
$tasks->addTask($this->taskExec('fire drush updb -- -y'));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running drush updb is not necessary here. If you are exporting configuration, you are likely trying to get configuration into the master branch. I suspect that you need to remove both drush updb and drush cr. If the plan is to "upgrade" the configuration usin gthe latest code, this this also doesn't do a great job because what ever branch you are on is going to have it's configuration blown away.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$tasks->addTask($this->taskExec('fire drush cr -- -y'));
$tasks->addTask($this->taskExec('fire drush cex -- -y'));
}
return $tasks;
}
}
3 changes: 3 additions & 0 deletions src/Robo/Plugin/Commands/GetDBCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public function getDB(ConsoleIO $io, array $args) {
}
break;
}
if (file_exists($dbFolder . '/site-db.sql.gz')) {
$tasks->addTask($this->taskFilesystemStack()->remove($dbFolder . '/site-db.sql.gz'));
}
$tasks->addTask($this->taskExec("$cmd")->args($args));

return $tasks;
Expand Down