bugfix mustal, upgrade remove stash, do reset instead

This commit is contained in:
OpenXE 2022-12-03 15:55:30 +00:00
commit 8cc64aee19
2 changed files with 16 additions and 8 deletions

View File

@ -452,7 +452,7 @@ function mustal_implode_with_quote(string $quote, string $delimiter, array $arra
// 10 Error on key definition upgrade
// 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) : int {
function mustal_calculate_db_upgrade(array $compare_def, array $db_def, array &$upgrade_sql, array $replacers) : int {
$upgrade_sql = array();
$compare_differences = mustal_compare_table_array($compare_def,"in JSON",$db_def,"in DB",true);

View File

@ -74,14 +74,14 @@ $remote_info = json_decode($remote_info_contents, true);
// Get changed files on system -> Should be empty
$output = array();
$retval = git("ls-files -m", $output,$verbose);
$retval = git("ls-files -m ..", $output,$verbose);
if ($retval != 0) {
abort("Error while executing git!");
}
if (!empty($output)) {
echo("There are modifed files:");
echo("There are modified files:");
echo_output($output);
if (!$force) {
abort("Clear modified files or use -f");
@ -98,10 +98,10 @@ if (file_exists($lockfile_name)) {
echo("--------------- Pulling files... ---------------\n");
if ($force) {
$retval = git("stash",$output,$verbose);
$retval = git("reset --hard",$output,$verbose);
if ($retval != 0) {
echo_output($output);
abort("Error while stashing files!");
abort("Error while resetting modified files!");
}
}
@ -111,6 +111,12 @@ if ($retval != 0) {
abort("Error while pulling files!");
}
$retval = git("reset --hard",$output,$verbose);
if ($retval != 0) {
echo_output($output);
abort("Error while applying files!");
}
echo("--------------- Files upgrade completed ---------------\n");
$retval = git("log -1 ",$output,$verbose);
if ($retval != 0) {
@ -143,7 +149,7 @@ echo("--------------- Calculating database upgrade for '$schema@$host'... ------
$upgrade_sql = array();
$result = mustal_calculate_db_upgrade($compare_def, $db_def, $upgrade_sql);
$result = mustal_calculate_db_upgrade($compare_def, $db_def, $upgrade_sql, $mustal_replacers);
if ($result != 0) {
echo("Error: $result\n");
@ -172,9 +178,10 @@ if (!$mysqli) {
echo("\rUpgrade step $counter of $number_of_statements... ");
$query_result = mysqli_query($mysqli, $sql);
if (!$query_result) {
$error = " not ok: ". mysqli_error($mysqli)."\n";
if (!$query_result) {
$error = " not ok: ". mysqli_error($mysqli);
echo($error);
echo("\n");
file_put_contents("./errors.txt",date()." ".$error.$sql."\n",FILE_APPEND);
$error_counter++;
} else {
@ -183,6 +190,7 @@ if (!$mysqli) {
}
echo("\n");
echo("$error_counter errors.\n");
if ($error_counter > 0) {
echo("See 'errors.txt'\n");