OXID-Deployer/recipe/shopTasks.php

63 regels
1.9 KiB
PHP

<?php
namespace Deployer;
desc('run all database migrations');
task('oxid:runMigration', [
'oxid:setShopsOffline',
'oxid:executeMigrations',
'oxid:setShopsOnline'
]);
require_once 'inc/database.php';
desc('set shops offline');
task('oxid:setShopsOffline', function() {
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}} -e "'.$query.'"');
} else {
warning('missing config, task skipped');
}
});
task('oxid:runMigration:failed', function() {
invoke('oxid:setShopsOnline');
})->hidden();
fail('oxid:runMigration', 'oxid:runMigration:failed');
desc('execute OXID Doctrine migrations');
task('oxid: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');
}
})->hidden();;
desc('set shops online');
task('oxid:setShopsOnline', function() {
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}} -e "'.$query.'"');
} else {
warning('missing config, task skipped');
}
});
desc('show version of current OXID installation');
task('oxid:getVersion', function () {
if (test("[ -f {{current_path}}/composer.lock ]")) {
cd('{{current_path}}');
info(
run(
'{{bin/composer}} show oxid-esales/oxideshop-ce | grep -ws "versions" | cut -d " " -f 4'
)
);
}
});
desc('dump contents from source to destination database');
task('oxid:cloneDatabase', function () {
invoke('database:clone');
});