Internal: Improve migration error handling and UI feedback

pull/5771/head
christianbeeznst 1 year ago
parent 1a0bef78d0
commit d7229541ea
  1. 13
      assets/vue/components/installer/Step6.vue
  2. 8
      public/main/install/install.lib.php
  3. 4
      public/main/install/migrate.php

@ -314,11 +314,14 @@
<div class="p-d-flex p-ai-center p-jc-center">
<p class="text-error">{{ errorMessage }}</p>
</div>
<div v-if="currentMigration" class="p-d-flex p-ai-center p-jc-center mt-4">
<p class="text-body-2">{{ t('The last migration executed successfully was:') }} <br /><strong>{{ currentMigration }}</strong></p>
</div>
<div class="formgroup-inline">
<div class="field">
<Button
:label="t('Contact Support')"
class="p-button-danger"
class="p-button-danger mt-4"
type="button"
@click="btnSupportOnClick"
/>
@ -358,7 +361,7 @@ function btnStep6OnClick() {
if (installerData.value.installType === 'update') {
startMigration(updatePath)
setTimeout(pollMigrationStatus, 7000)
setTimeout(pollMigrationStatus, 5000)
} else {
isExecutable.value = "step6"
document.getElementById("install_form").submit()
@ -372,7 +375,9 @@ function startMigration(updatePath) {
loading.value = false
isButtonDisabled.value = false
errorDialogVisible.value = true
errorMessage.value = `${t('Migration request failed with status:')} ${xhr.status}`
errorMessage.value = `
${t('Please check the following error:')} ${xhr.status} - ${xhr.statusText}.
`
}
};
@ -401,7 +406,7 @@ function pollMigrationStatus() {
loading.value = false
isButtonDisabled.value = false
errorDialogVisible.value = true
errorMessage.value = `${t('Migration request failed with status:')} ${xhr.status}`
errorMessage.value = `${t('Please check the following error:')} ${xhr.status} - ${xhr.statusText}`
}
};

@ -1877,10 +1877,11 @@ function executeMigration(): array
'current_migration' => '',
];
Database::setManager(initializeEntityManager());
$manager = Database::getManager();
$connection = $manager->getConnection();
try {
Database::setManager(initializeEntityManager());
$manager = Database::getManager();
$connection = $manager->getConnection();
$config = new PhpFile(api_get_path(SYS_CODE_PATH) . 'install/migrations.php');
$dependency = DependencyFactory::fromConnection($config, new ExistingConnection($connection));
@ -1920,6 +1921,7 @@ function executeMigration(): array
$resultStatus['current_migration'] = getLastExecutedMigration($connection);
} catch (Exception $e) {
$resultStatus['current_migration'] = getLastExecutedMigration($connection);
$resultStatus['message'] = 'Migration failed: ' . $e->getMessage();
}

@ -21,6 +21,10 @@ if (file_exists($logFile)) {
$logContent = file_get_contents($logFile);
}
if (!$response['status']) {
http_response_code(500); // Return a 500 Internal Server Error if migration failed
}
$response = [
'log_terminal' => '<pre class="terminal">' . $logContent . '</pre>',
'progress_percentage' => $response['progress_percentage'],

Loading…
Cancel
Save