extract helper functions
Dieser Commit ist enthalten in:
Ursprung
0c66cec2a2
Commit
7deab9c67f
19
recipe/inc/database.php
Normale Datei
19
recipe/inc/database.php
Normale Datei
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Deployer;
|
||||
|
||||
set('database_configured', function() {
|
||||
return has('db_name') && strlen(get('db_name')) &&
|
||||
has('db_conf_path') && strlen(get('db_conf_path')) && test("[ -f {{db_conf_path}} ]");
|
||||
});
|
||||
|
||||
set('mysql_configured', function() {
|
||||
return has('bin/mysql') && strlen(get('bin/mysql')) &&
|
||||
get('database_configured');
|
||||
});
|
||||
|
||||
set('mysqldump_configured', function() {
|
||||
return has('bin/mysql') && strlen(get('bin/mysql')) &&
|
||||
get('database_configured');
|
||||
});
|
||||
|
@ -9,12 +9,11 @@ task('shop:runMigration', [
|
||||
'shop:setShopsOnline'
|
||||
]);
|
||||
|
||||
require_once 'inc/database.php';
|
||||
|
||||
desc('set shops offline');
|
||||
task('shop:setShopsOffline', function() {
|
||||
if (has('bin/mysql') && strlen(get('bin/mysql')) &&
|
||||
has('db_name') && strlen(get('db_name')) &&
|
||||
has('db_conf_path') && strlen(get('db_conf_path')) && test("[ -f {{db_conf_path}} ]")
|
||||
) {
|
||||
if (get('mysql_configured')) {
|
||||
$query = "UPDATE oxshops SET oxactive = '0', OXREGISTERSUBJECT = CONCAT('..', OXREGISTERSUBJECT) WHERE oxactive = '1';";
|
||||
run('{{bin/mysql}} --defaults-extra-file={{db_conf_path}} {{db_name}} -e "'.$query.'"');
|
||||
} else {
|
||||
@ -37,10 +36,7 @@ task('shop:executeMigrations', function () {
|
||||
|
||||
desc('set shops online');
|
||||
task('shop:setShopsOnline', function() {
|
||||
if (has('bin/mysql') && strlen(get('bin/mysql')) &&
|
||||
has('db_name') && strlen(get('db_name')) &&
|
||||
has('db_conf_path') && strlen(get('db_conf_path')) && test("[ -f {{db_conf_path}} ]")
|
||||
) {
|
||||
if (get('mysql_configured')) {
|
||||
$query = "UPDATE oxshops SET oxactive = '1', OXREGISTERSUBJECT = SUBSTR(OXREGISTERSUBJECT, 3) WHERE oxactive = '0' AND OXREGISTERSUBJECT LIKE '..%';";
|
||||
run('{{bin/mysql}} --defaults-extra-file={{db_conf_path}} {{db_name}} -e "'.$query.'"');
|
||||
} else {
|
||||
@ -62,11 +58,7 @@ task('shop:getVersion', function () {
|
||||
|
||||
desc('dump contents from source to destination database');
|
||||
task('shop:cloneDatabase', function () {
|
||||
if (has('bin/mysql') && strlen(get('bin/mysql')) &&
|
||||
has('bin/mysqldump') && strlen(get('bin/mysqldump')) &&
|
||||
has('db_name') && strlen(get('db_name')) &&
|
||||
has('db_conf_path') && strlen(get('db_conf_path')) && test("[ -f {{db_conf_path}} ]")
|
||||
) {
|
||||
if (get('mysql_configured') && get('mysqldump_configured')) {
|
||||
info('Note: Use a dedicated read only user for accessing the source database.');
|
||||
info('Using the following source database:');
|
||||
$source_host = ask('source database host', 'localhost');
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren