68 Zeilen
2.0 KiB
PHP
68 Zeilen
2.0 KiB
PHP
<?php
|
|
namespace Deployer;
|
|
|
|
require 'recipe/composer.php';
|
|
|
|
// Setup
|
|
|
|
import(__DIR__. '/inventory.yml');
|
|
|
|
// Hooks
|
|
|
|
after('deploy:failed', 'deploy:unlock');
|
|
after('deploy:vendors', 'deploy:d3OxidTasks');
|
|
|
|
/// Tasks
|
|
|
|
desc('Oxid related tasks');
|
|
task('deploy:d3OxidTasks', [
|
|
'deploy:clear_paths'
|
|
]);
|
|
|
|
desc('run all database migrations');
|
|
task('migrate', [
|
|
'migrate:setShopsOffline',
|
|
'migrate:executeMigrations',
|
|
'migrate:setShopsOnline'
|
|
]);
|
|
|
|
desc('set shops offline');
|
|
task('migrate: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}} ]")
|
|
) {
|
|
$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 {
|
|
info('missing config, task skipped');
|
|
}
|
|
});
|
|
|
|
task('migrate:failed', function() {
|
|
invoke('migrate:setShopsOnline');
|
|
})->hidden();
|
|
|
|
fail('migrate', 'migrate:failed');
|
|
|
|
desc('execute OXID Doctrine migrations');
|
|
task('migrate:executeMigrations', function () {
|
|
if (test("[ -f {{current_path}}/vendor/bin/oe-eshop-doctrine_migration ]")) {
|
|
run('{{bin/php}} {{current_path}}/vendor/bin/oe-eshop-doctrine_migration migrations:migrate');
|
|
}
|
|
});
|
|
|
|
desc('set shops online');
|
|
task('migrate: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}} ]")
|
|
) {
|
|
$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 {
|
|
info('missing config, task skipped');
|
|
}
|
|
});
|
|
|