From f308816d5a71ce41554f1b9476e0872548372819 Mon Sep 17 00:00:00 2001 From: George Gastaldi Date: Mon, 31 Jul 2023 09:20:04 -0300 Subject: [PATCH] Return the FlywayResponse on error Confirm before cleaning --- .../main/resources/dev-ui/qwc-flyway-datasources.js | 10 ++++++---- .../flyway/runtime/devui/FlywayJsonRpcService.java | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/extensions/flyway/deployment/src/main/resources/dev-ui/qwc-flyway-datasources.js b/extensions/flyway/deployment/src/main/resources/dev-ui/qwc-flyway-datasources.js index 8ae34130bfdc7..0057a64087972 100644 --- a/extensions/flyway/deployment/src/main/resources/dev-ui/qwc-flyway-datasources.js +++ b/extensions/flyway/deployment/src/main/resources/dev-ui/qwc-flyway-datasources.js @@ -136,9 +136,11 @@ export class QwcFlywayDatasources extends QwcHotReloadElement { } _clean(ds) { - this.jsonRpc.clean({ds: ds.name}).then(jsonRpcResponse => { - this._showResultNotification(jsonRpcResponse.result); - }); + if (confirm('This will drop all objects (tables, views, procedures, triggers, ...) in the configured schema. Do you want to continue?')) { + this.jsonRpc.clean({ds: ds.name}).then(jsonRpcResponse => { + this._showResultNotification(jsonRpcResponse.result); + }); + } } _migrate(ds) { @@ -170,4 +172,4 @@ export class QwcFlywayDatasources extends QwcHotReloadElement { } } -customElements.define('qwc-flyway-datasources', QwcFlywayDatasources); \ No newline at end of file +customElements.define('qwc-flyway-datasources', QwcFlywayDatasources); diff --git a/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/devui/FlywayJsonRpcService.java b/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/devui/FlywayJsonRpcService.java index a5d1c905a2627..11ca2f9d8e090 100644 --- a/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/devui/FlywayJsonRpcService.java +++ b/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/devui/FlywayJsonRpcService.java @@ -153,7 +153,7 @@ public FlywayActionResponse create(String ds) { return new FlywayActionResponse("success", "Initial migration created, Flyway will now manage this datasource"); } catch (Throwable t) { - new FlywayActionResponse("error", t.getMessage()); + return new FlywayActionResponse("error", t.getMessage()); } } return errorNoScript(ds); @@ -184,7 +184,7 @@ private Flyway getFlyway(String ds) { return null; } - static class FlywayDatasource { + public static class FlywayDatasource { public String name; public boolean hasMigrations; public boolean createPossible; @@ -199,7 +199,7 @@ public FlywayDatasource(String name, boolean hasMigrations, boolean createPossib } } - static class FlywayActionResponse { + public static class FlywayActionResponse { public String type; public String message; public int number;