-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a09032
commit 3f69149
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
|
||
Changelog | ||
--------- | ||
master | ||
~~~~~~ | ||
|
||
1) [FEATURE] Add db:push command. | ||
|
||
9.0.0 | ||
~~~~~~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Deployer; | ||
|
||
use SourceBroker\DeployerExtendedDatabase\Utility\ConsoleUtility; | ||
use Deployer\Exception\GracefulShutdownException; | ||
|
||
/* | ||
* @see https://github.com/sourcebroker/deployer-extended-database#db-push | ||
*/ | ||
task('db:push', function () { | ||
$targetName = get('argument_stage'); | ||
if (null !== $targetName) { | ||
if (!get('db_allow_push_live', false) && $targetName === get('instance_live_name', 'live')) { | ||
throw new GracefulShutdownException( | ||
'FORBIDDEN: For security its forbidden to push media to "' | ||
. get('instance_live_name', 'live') . '" instance!' . | ||
' Use "set(\'db_allow_push_live\', true);" to allow this. [Error code: 1488149981778]' | ||
); | ||
} | ||
} else { | ||
throw new GracefulShutdownException("The target instance is required for media:push command. [Error code: 1488149981776]"); | ||
} | ||
|
||
$dumpCode = md5(microtime(true) . rand(0, 10000)); | ||
$dl = get('local/bin/deployer'); | ||
$verbosity = (new ConsoleUtility())->getVerbosityAsParameter(); | ||
$options = (new ConsoleUtility())->getOptionsForCliUsage(['dumpcode' => $dumpCode]); | ||
runLocally($dl . ' db:export ' . $options . ' ' . $verbosity); | ||
runLocally($dl . ' db:upload ' . $targetName . ' ' . $options . ' ' . $verbosity); | ||
runLocally($dl . ' db:process ' . $targetName . ' ' . $options . ' ' . $verbosity); | ||
runLocally($dl . ' db:import ' . $targetName . ' ' . $options . ' ' . $verbosity); | ||
runLocally($dl . ' db:rmdump ' . $targetName . ' ' . $options . ' ' . $verbosity); | ||
})->desc('Copy database from local to remote'); |