From ff2dca8a70cd6335d2ffd95b24b4fab46e7e38d3 Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Sun, 20 Oct 2024 19:46:14 +0000 Subject: [PATCH] ApplicationService: Apply migrations before starting services --- .../src/main/java/bisq/application/ApplicationService.java | 7 ++++++- .../java/bisq/desktop_app/DesktopApplicationService.java | 3 ++- .../bisq/oracle_node/OracleNodeApplicationService.java | 3 ++- .../main/java/bisq/rest_api/RestApiApplicationService.java | 3 ++- .../java/bisq/seed_node/SeedNodeApplicationService.java | 3 ++- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/application/src/main/java/bisq/application/ApplicationService.java b/application/src/main/java/bisq/application/ApplicationService.java index 7bbf3a0f80..393bc9e1b8 100644 --- a/application/src/main/java/bisq/application/ApplicationService.java +++ b/application/src/main/java/bisq/application/ApplicationService.java @@ -17,6 +17,7 @@ package bisq.application; +import bisq.application.migration.MigrationService; import bisq.common.application.ApplicationVersion; import bisq.common.application.DevMode; import bisq.common.application.OptionUtils; @@ -124,6 +125,7 @@ public Config(Path baseDir, protected final Config config; @Getter protected final PersistenceService persistenceService; + private final MigrationService migrationService; @SuppressWarnings("FieldCanBeLocal") // Pin it so that it does not get GC'ed private final MemoryReport memoryReport; private FileLock instanceLock; @@ -185,6 +187,7 @@ public ApplicationService(String configFileName, String[] args) { String absoluteDataDirPath = dataDir.toAbsolutePath().toString(); persistenceService = new PersistenceService(absoluteDataDirPath); + migrationService = new MigrationService(dataDir); } private void checkInstanceLock() { @@ -207,7 +210,9 @@ public CompletableFuture readAllPersisted() { return persistenceService.readAllPersisted(); } - public abstract CompletableFuture initialize(); + public CompletableFuture initialize() { + return migrationService.runMigrations(); + } public abstract CompletableFuture shutdown(); diff --git a/apps/desktop/desktop-app/src/main/java/bisq/desktop_app/DesktopApplicationService.java b/apps/desktop/desktop-app/src/main/java/bisq/desktop_app/DesktopApplicationService.java index f93aad409b..007e8e9e6a 100644 --- a/apps/desktop/desktop-app/src/main/java/bisq/desktop_app/DesktopApplicationService.java +++ b/apps/desktop/desktop-app/src/main/java/bisq/desktop_app/DesktopApplicationService.java @@ -219,7 +219,8 @@ public DesktopApplicationService(String[] args, ShutDownHandler shutDownHandler) @Override public CompletableFuture initialize() { - return securityService.initialize() + return super.initialize() + .thenCompose(result -> securityService.initialize()) .thenCompose(result -> { setState(State.INITIALIZE_NETWORK); diff --git a/apps/oracle-node-app/src/main/java/bisq/oracle_node/OracleNodeApplicationService.java b/apps/oracle-node-app/src/main/java/bisq/oracle_node/OracleNodeApplicationService.java index 2247f0d8d8..9e0a102e6a 100644 --- a/apps/oracle-node-app/src/main/java/bisq/oracle_node/OracleNodeApplicationService.java +++ b/apps/oracle-node-app/src/main/java/bisq/oracle_node/OracleNodeApplicationService.java @@ -80,7 +80,8 @@ public OracleNodeApplicationService(String[] args) { @Override public CompletableFuture initialize() { - return securityService.initialize() + return super.initialize() + .thenCompose(result -> securityService.initialize()) .thenCompose(result -> networkService.initialize()) .thenCompose(result -> identityService.initialize()) .thenCompose(result -> bondedRolesService.initialize()) diff --git a/apps/rest-api-app/src/main/java/bisq/rest_api/RestApiApplicationService.java b/apps/rest-api-app/src/main/java/bisq/rest_api/RestApiApplicationService.java index 6f5fd3c579..4376b746e8 100644 --- a/apps/rest-api-app/src/main/java/bisq/rest_api/RestApiApplicationService.java +++ b/apps/rest-api-app/src/main/java/bisq/rest_api/RestApiApplicationService.java @@ -167,7 +167,8 @@ public RestApiApplicationService(String[] args) { @Override public CompletableFuture initialize() { - return securityService.initialize() + return super.initialize() + .thenCompose(result -> securityService.initialize()) .thenCompose(result -> { setState(State.INITIALIZE_NETWORK); diff --git a/apps/seed-node-app/src/main/java/bisq/seed_node/SeedNodeApplicationService.java b/apps/seed-node-app/src/main/java/bisq/seed_node/SeedNodeApplicationService.java index fcc5669da9..ae473a669d 100644 --- a/apps/seed-node-app/src/main/java/bisq/seed_node/SeedNodeApplicationService.java +++ b/apps/seed-node-app/src/main/java/bisq/seed_node/SeedNodeApplicationService.java @@ -75,7 +75,8 @@ public SeedNodeApplicationService(String[] args) { @Override public CompletableFuture initialize() { - return securityService.initialize() + return super.initialize() + .thenCompose(result -> securityService.initialize()) .thenCompose(result -> networkService.initialize()) .thenCompose(result -> identityService.initialize()) .thenCompose(result -> bondedRolesService.initialize())