remove db_name configuration

This commit is contained in:
2024-11-01 21:49:52 +01:00
parent d98a79efce
commit 05b7443a3a
3 changed files with 10 additions and 9 deletions

View File

@ -9,13 +9,14 @@ task('shop:runMigration', [
'shop:setShopsOnline'
]);
require_once 'inc/database.php';
desc('set shops offline');
task('shop: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}} {{db_name}} -e "'.$query.'"');
run('{{bin/mysql}} --defaults-extra-file={{db_conf_path}} -e "'.$query.'"');
} else {
warning('missing config, task skipped');
}
@ -38,7 +39,7 @@ desc('set shops online');
task('shop: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}} {{db_name}} -e "'.$query.'"');
run('{{bin/mysql}} --defaults-extra-file={{db_conf_path}} -e "'.$query.'"');
} else {
warning('missing config, task skipped');
}
@ -66,10 +67,11 @@ task('shop:cloneDatabase', function () {
$source_name = ask('source database name');
$source_user = ask('source database user');
$source_pass = askHiddenResponse('source database password');
if (askConfirmation('Do you really want to clone from "'.$source_name.'" to "{{db_name}}"? The target database "{{db_name}}" will be overwritten!')) {
$target_name = parse_ini_file(get('db_conf_path'))['database'];
if (askConfirmation('Do you really want to clone from "'.$source_name.'" to "'.$target_name.'"? The target database "'.$target_name.'" will be overwritten!')) {
info('cloning database');
$auth = "-h".$source_host." -P".$source_port." -u".$source_user." -p'".$source_pass."'";
run("{{bin/mysqldump}} ".$auth." --opt --no-create-db -f ".$source_name." $({{bin/mysql}} ".$auth." -ANe\"SET group_concat_max_len = 10485760; SELECT GROUP_CONCAT(table_name SEPARATOR ' ') FROM information_schema.tables WHERE table_schema='".$source_name."' AND engine IS NOT NULL;\") | {{bin/mysql}} --defaults-extra-file={{db_conf_path}} -f {{db_name}}");
run("{{bin/mysqldump}} ".$auth." --opt --no-create-db -f ".$source_name." $({{bin/mysql}} ".$auth." -ANe\"SET group_concat_max_len = 10485760; SELECT GROUP_CONCAT(table_name SEPARATOR ' ') FROM information_schema.tables WHERE table_schema='".$source_name."' AND engine IS NOT NULL;\") | {{bin/mysql}} --defaults-extra-file={{db_conf_path}} -f");
info('creating views');
run('{{release_or_current_path}}/vendor/bin/oe-eshop-db_views_regenerate');
info('successfully finished');