-
RIP
+ Failure
diff --git a/install/js/install-script.js b/install/js/install-script.js
index 097fc242..c6adcc0f 100644
--- a/install/js/install-script.js
+++ b/install/js/install-script.js
@@ -85,12 +85,12 @@ function installOrUpdate() {
$('[data-step="install-or-update"] > .progress').show();
// Recursive call that will increment by 1 each time
- executeMigration(startingMigrationNumber, data.lastMigrationNumber, 'up');
+ executeMigration(startingMigrationNumber, startingMigrationNumber, data.lastMigrationNumber, 'up');
}
})
}
-function executeMigration(migrationNumber, latestMigrationNumber, direction) {
+function executeMigration(startingMigrationNumber, migrationNumber, latestMigrationNumber, direction) {
var heskPath = $('p#hesk-path').text();
$.ajax({
@@ -104,13 +104,13 @@ function executeMigration(migrationNumber, latestMigrationNumber, direction) {
console.log('migrationNumber: ' + migrationNumber);
console.log('latestMigrationNumber: ' + latestMigrationNumber);
console.info('---');
- if (migrationNumber === latestMigrationNumber || (migrationNumber === 1 && direction === 'down')) {
+ if (migrationNumber === latestMigrationNumber || (migrationNumber === startingMigrationNumber && direction === 'down')) {
updateProgressBar(migrationNumber, latestMigrationNumber, direction === 'down', true);
console.log('%c Success! ', 'color: white; background-color: green; font-size: 2em');
} else {
updateProgressBar(migrationNumber, latestMigrationNumber, false, false);
var newMigrationNumber = direction === 'up' ? migrationNumber + 1 : migrationNumber - 1;
- executeMigration(newMigrationNumber, latestMigrationNumber, direction);
+ executeMigration(startingMigrationNumber, newMigrationNumber, latestMigrationNumber, direction);
}
},
error: function(response) {
@@ -126,7 +126,7 @@ function executeMigration(migrationNumber, latestMigrationNumber, direction) {
if (direction === 'up') {
// Revert!
- executeMigration(migrationNumber - 1, latestMigrationNumber, 'down');
+ executeMigration(startingMigrationNumber, migrationNumber - 1, latestMigrationNumber, 'down');
} else {
console.error("I even failed to roll back. Yikes! :'(");
}
diff --git a/install/js/uninstall-script.js b/install/js/uninstall-script.js
index edb0b833..af0cad5c 100644
--- a/install/js/uninstall-script.js
+++ b/install/js/uninstall-script.js
@@ -85,12 +85,12 @@ function uninstall() {
$('[data-step="uninstall"] > .progress').show();
// Recursive call that will increment by 1 each time
- executeMigration(startingMigrationNumber, 1, 'down');
+ executeMigration(startingMigrationNumber, startingMigrationNumber, 1, 'down');
}
})
}
-function executeMigration(migrationNumber, latestMigrationNumber, direction) {
+function executeMigration(startingMigrationNumber, migrationNumber, latestMigrationNumber, direction) {
var heskPath = $('p#hesk-path').text();
$.ajax({
@@ -105,12 +105,12 @@ function executeMigration(migrationNumber, latestMigrationNumber, direction) {
console.log('latestMigrationNumber: ' + latestMigrationNumber);
console.info('---');
if (migrationNumber === latestMigrationNumber) {
- updateProgressBar(migrationNumber, latestMigrationNumber, false, true);
+ updateProgressBar(startingMigrationNumber, migrationNumber, false, true);
console.log('%c Success! ', 'color: white; background-color: green; font-size: 2em');
} else {
- updateProgressBar(migrationNumber, latestMigrationNumber, false, false);
+ updateProgressBar(startingMigrationNumber, migrationNumber, false, false);
var newMigrationNumber = direction === 'up' ? migrationNumber + 1 : migrationNumber - 1;
- executeMigration(newMigrationNumber, latestMigrationNumber, direction);
+ executeMigration(startingMigrationNumber, newMigrationNumber, latestMigrationNumber, direction);
}
},
error: function(response) {
@@ -122,14 +122,14 @@ function executeMigration(migrationNumber, latestMigrationNumber, direction) {
$errorBlock = $('#error-block');
$errorBlock.html($errorBlock.html() + "
An error occurred! (Error Code: " + migrationNumber + ")
" + message).show();
- updateProgressBar(migrationNumber, latestMigrationNumber, true, false);
+ updateProgressBar(startingMigrationNumber, migrationNumber, true, false);
console.error(message);
}
})
}
-function updateProgressBar(migrationNumber, latestMigrationNumber, isError, isFinished) {
+function updateProgressBar(startingMigrationNumber, migrationNumber, isError, isFinished) {
var $progressBar = $('#progress-bar');
if (isError === true) {
@@ -141,7 +141,7 @@ function updateProgressBar(migrationNumber, latestMigrationNumber, isError, isFi
$errorBlock.html($errorBlock.html() + '
Successfully reverted database to before uninstalling.');
}
} else {
- var percentage = Math.round(migrationNumber / latestMigrationNumber * 100);
+ var percentage = Math.round((startingMigrationNumber - migrationNumber) / startingMigrationNumber * 100);
$progressBar.find('.progress-bar').css('width', percentage + '%');
}
diff --git a/install/uninstall.php b/install/uninstall.php
index 0ba8272b..340f4b32 100644
--- a/install/uninstall.php
+++ b/install/uninstall.php
@@ -87,7 +87,7 @@ if (hesk_dbNumRows($tableSql) > 0) {
-
I hoped you wouldn't be here, but let's continue anyway. ðŸ˜
+
I hoped you wouldn't be here, but let's continue anyway.