mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-25 06:00:28 +01:00
upgrade added strict DB mode
This commit is contained in:
parent
5816dedbc0
commit
7ffb9a86a5
@ -113,6 +113,12 @@ if (php_sapi_name() == "cli") {
|
||||
} else {
|
||||
}
|
||||
|
||||
if (in_array('-strict', $argv)) {
|
||||
$strict_db = true;
|
||||
} else {
|
||||
$strict_db = false;
|
||||
}
|
||||
|
||||
if (in_array('-do', $argv)) {
|
||||
if (!$check_git && !$check_db) {
|
||||
$do_git = true;
|
||||
@ -127,7 +133,17 @@ if (php_sapi_name() == "cli") {
|
||||
}
|
||||
|
||||
if ($check_git || $check_db || $do_git || $do_db) {
|
||||
upgrade_main($directory,$verbose,$check_git,$do_git,$export_db,$check_db,$do_db,$force,$connection,$origin);
|
||||
upgrade_main( directory: $directory,
|
||||
verbose: $verbose,
|
||||
check_git: $check_git,
|
||||
do_git: $do_git,
|
||||
export_db: $export_db,
|
||||
check_db: $check_db,
|
||||
strict_db: $strict_db,
|
||||
do_db: $do_db,
|
||||
force: $force,
|
||||
connection: $connection,
|
||||
origin: $origin);
|
||||
} else {
|
||||
info();
|
||||
}
|
||||
@ -139,7 +155,7 @@ if (php_sapi_name() == "cli") {
|
||||
}
|
||||
// -------------------------------- END
|
||||
|
||||
function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $do_db, bool $force, bool $connection, bool $origin) {
|
||||
function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $strict_db, bool $do_db, bool $force, bool $connection, bool $origin) {
|
||||
|
||||
$mainfolder = dirname($directory);
|
||||
$datafolder = $directory."/data";
|
||||
@ -379,7 +395,7 @@ function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do
|
||||
echo_out("--------------- Calculating database upgrade for '$schema@$host'... ---------------\n");
|
||||
|
||||
$upgrade_sql = array();
|
||||
$result = mustal_calculate_db_upgrade($compare_def, $db_def, $upgrade_sql, $mustal_replacers);
|
||||
$result = mustal_calculate_db_upgrade($compare_def, $db_def, $upgrade_sql, $mustal_replacers, $strict_db);
|
||||
|
||||
if (!empty($result)) {
|
||||
abort(count($result)." errors.\n");
|
||||
@ -482,6 +498,7 @@ function info() {
|
||||
echo_out("\t-f: force override of existing files\n");
|
||||
echo_out("\t-o: update from origin instead of remote.json\n");
|
||||
echo_out("\t-connection use connection.json in data folder instead of user.inc.php\n");
|
||||
echo_out("\t-strict: innodb_strict_mode=ON\n");
|
||||
echo_out("\t-clean: (not yet implemented) create the needed SQL to remove items from the database not in the JSON\n");
|
||||
echo_out("\n");
|
||||
}
|
||||
|
10
vendor/mustal/mustal_mysql_upgrade_tool.php
vendored
10
vendor/mustal/mustal_mysql_upgrade_tool.php
vendored
@ -21,7 +21,7 @@ function mustal_compare_table_array(array $nominal, string $nominal_name, array
|
||||
Compare two database structures
|
||||
Returns a structured array containing information on all the differences.
|
||||
|
||||
function mustal_calculate_db_upgrade(array $compare_def, array $db_def, array &$upgrade_sql) : int
|
||||
function mustal_calculate_db_upgrade(array $compare_def, array $db_def, array &$upgrade_sql, bool $strict) : int
|
||||
Generate the SQL needed to upgrade the database to match the definition, based on a comparison.
|
||||
|
||||
Data structure in Array and JSON
|
||||
@ -542,7 +542,7 @@ function mustal_implode_with_quote(string $quote, string $delimiter, array $arra
|
||||
// 11 Table type upgrade not supported
|
||||
// 12 Upgrade type not supported
|
||||
|
||||
function mustal_calculate_db_upgrade(array $compare_def, array $db_def, array &$upgrade_sql, array $replacers) : array {
|
||||
function mustal_calculate_db_upgrade(array $compare_def, array $db_def, array &$upgrade_sql, array $replacers, bool $strict) : array {
|
||||
|
||||
$result = array();
|
||||
$upgrade_sql = array();
|
||||
@ -752,8 +752,10 @@ function mustal_calculate_db_upgrade(array $compare_def, array $db_def, array &$
|
||||
$upgrade_sql = array_unique($upgrade_sql);
|
||||
|
||||
if (count($upgrade_sql) > 0) {
|
||||
|
||||
array_unshift($upgrade_sql,"SET SQL_MODE='ALLOW_INVALID_DATES';","SET SESSION innodb_strict_mode=OFF;");
|
||||
array_unshift($upgrade_sql,"SET SQL_MODE='ALLOW_INVALID_DATES';");
|
||||
if (!$strict) {
|
||||
array_unshift($upgrade_sql,"SET SESSION innodb_strict_mode=OFF;");
|
||||
}
|
||||
}
|
||||
|
||||
return($result);
|
||||
|
@ -41,29 +41,71 @@ class upgrade {
|
||||
$this->app->Tpl->Set('UPGRADE_VISIBLE', "hidden");
|
||||
$this->app->Tpl->Set('UPGRADE_DB_VISIBLE', "hidden");
|
||||
|
||||
//function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $do_db, bool $force, bool $connection, bool $origin) {
|
||||
|
||||
$directory = dirname(getcwd())."/upgrade";
|
||||
|
||||
switch ($submit) {
|
||||
case 'check_upgrade':
|
||||
$this->app->Tpl->Set('UPGRADE_VISIBLE', "");
|
||||
unlink($logfile);
|
||||
upgrade_main($directory,$verbose,true,false,false,true,false,$force,false,false);
|
||||
upgrade_main( directory: $directory,
|
||||
verbose: $verbose,
|
||||
check_git: true,
|
||||
do_git: false,
|
||||
export_db: false,
|
||||
check_db: true,
|
||||
strict_db: false,
|
||||
do_db: false,
|
||||
force: $force,
|
||||
connection: false,
|
||||
origin: false
|
||||
);
|
||||
break;
|
||||
case 'do_upgrade':
|
||||
unlink($logfile);
|
||||
upgrade_main($directory,$verbose,true,true,false,true,true,$force,false,false);
|
||||
upgrade_main( directory: $directory,
|
||||
verbose: $verbose,
|
||||
check_git: true,
|
||||
do_git: true,
|
||||
export_db: false,
|
||||
check_db: true,
|
||||
strict_db: false,
|
||||
do_db: true,
|
||||
force: $force,
|
||||
connection: false,
|
||||
origin: false
|
||||
);
|
||||
break;
|
||||
case 'check_db':
|
||||
$this->app->Tpl->Set('UPGRADE_DB_VISIBLE', "");
|
||||
unlink($logfile);
|
||||
upgrade_main($directory,$db_verbose,false,false,false,true,false,$force,false,false);
|
||||
upgrade_main( directory: $directory,
|
||||
verbose: $db_verbose,
|
||||
check_git: false,
|
||||
do_git: false,
|
||||
export_db: false,
|
||||
check_db: true,
|
||||
strict_db: false,
|
||||
do_db: false,
|
||||
force: $force,
|
||||
connection: false,
|
||||
origin: false
|
||||
);
|
||||
break;
|
||||
case 'do_db_upgrade':
|
||||
$this->app->Tpl->Set('UPGRADE_DB_VISIBLE', "");
|
||||
unlink($logfile);
|
||||
upgrade_main($directory,$db_verbose,false,false,false,true,true,$force,false,false);
|
||||
upgrade_main( directory: $directory,
|
||||
verbose: $db_verbose,
|
||||
check_git: false,
|
||||
do_git: false,
|
||||
export_db: false,
|
||||
check_db: true,
|
||||
strict_db: false,
|
||||
do_db: true,
|
||||
force: $force,
|
||||
connection: false,
|
||||
origin: false
|
||||
);
|
||||
break;
|
||||
case 'refresh':
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user