Some changes
This commit is contained in:
parent
78559de051
commit
f5907bf476
@ -106,7 +106,7 @@ function executeMigration(migrationNumber, latestMigrationNumber, direction) {
|
|||||||
console.info('---');
|
console.info('---');
|
||||||
if (migrationNumber === latestMigrationNumber || (migrationNumber === 1 && direction === 'down')) {
|
if (migrationNumber === latestMigrationNumber || (migrationNumber === 1 && direction === 'down')) {
|
||||||
updateProgressBar(migrationNumber, latestMigrationNumber, direction === 'down', true);
|
updateProgressBar(migrationNumber, latestMigrationNumber, direction === 'down', true);
|
||||||
console.log('DONE');
|
console.log('%c Success! ', 'color: white; background-color: green; font-size: 2em');
|
||||||
} else {
|
} else {
|
||||||
updateProgressBar(migrationNumber, latestMigrationNumber, false, false);
|
updateProgressBar(migrationNumber, latestMigrationNumber, false, false);
|
||||||
var newMigrationNumber = direction === 'up' ? migrationNumber + 1 : migrationNumber - 1;
|
var newMigrationNumber = direction === 'up' ? migrationNumber + 1 : migrationNumber - 1;
|
||||||
@ -120,7 +120,15 @@ function executeMigration(migrationNumber, latestMigrationNumber, direction) {
|
|||||||
message = response.responseText;
|
message = response.responseText;
|
||||||
}
|
}
|
||||||
$('#error-block').html("An error occurred! (Error Code: " + migrationNumber + ")<br>" + message).show();
|
$('#error-block').html("An error occurred! (Error Code: " + migrationNumber + ")<br>" + message).show();
|
||||||
updateProgressBar(migrationNumber, latestMigrationNumber, true, true);
|
|
||||||
|
updateProgressBar(migrationNumber, latestMigrationNumber, true, false);
|
||||||
|
|
||||||
|
if (direction === 'up') {
|
||||||
|
// Revert!
|
||||||
|
executeMigration(migrationNumber - 1, 1, 'down');
|
||||||
|
} else {
|
||||||
|
console.error("I even failed to roll back. Yikes! :'(");
|
||||||
|
}
|
||||||
console.error(message);
|
console.error(message);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -136,8 +144,6 @@ function updateProgressBar(migrationNumber, latestMigrationNumber, isError, isFi
|
|||||||
if (isFinished) {
|
if (isFinished) {
|
||||||
var $errorBlock = $('#error-block');
|
var $errorBlock = $('#error-block');
|
||||||
$errorBlock.html($errorBlock.html() + '<br><br>Successfully reverted database to before the installation/update.');
|
$errorBlock.html($errorBlock.html() + '<br><br>Successfully reverted database to before the installation/update.');
|
||||||
} else {
|
|
||||||
executeMigration(migrationNumber - 1, latestMigrationNumber, 'down', true);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var percentage = Math.round(migrationNumber / latestMigrationNumber * 100);
|
var percentage = Math.round(migrationNumber / latestMigrationNumber * 100);
|
||||||
|
14
install/js/migration-handler.js
Normal file
14
install/js/migration-handler.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
function executeMigration(migrationNumber, direction, success, error) {
|
||||||
|
var heskPath = $('p#hesk-path').text();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: heskPath + 'install/ajax/process-migration.php',
|
||||||
|
method: 'POST',
|
||||||
|
data: JSON.stringify({
|
||||||
|
migrationNumber: migrationNumber,
|
||||||
|
direction: direction
|
||||||
|
}),
|
||||||
|
success: success(data),
|
||||||
|
error: error(data)
|
||||||
|
})
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user