From edae2f5a613d83c8102e27e63527036cb1f930b9 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Fri, 28 Jun 2024 03:34:34 +0000
Subject: [PATCH 1/2] Update dependency
com.manticore-projects.tools:h2migrationtool to v1.6
---
commafeed-server/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/commafeed-server/pom.xml b/commafeed-server/pom.xml
index 5c787456..e6757439 100644
--- a/commafeed-server/pom.xml
+++ b/commafeed-server/pom.xml
@@ -403,7 +403,7 @@
com.manticore-projects.tools
h2migrationtool
- 1.4
+ 1.6
From e3688107313002f263bb8fe007e0c7af3f4b85c1 Mon Sep 17 00:00:00 2001
From: Athou
Date: Fri, 28 Jun 2024 07:16:42 +0200
Subject: [PATCH 2/2] adapt script to new H2MigrationTool file output name
---
.../commafeed/backend/service/db/H2MigrationService.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/commafeed-server/src/main/java/com/commafeed/backend/service/db/H2MigrationService.java b/commafeed-server/src/main/java/com/commafeed/backend/service/db/H2MigrationService.java
index 616ed75a..75b839c4 100644
--- a/commafeed-server/src/main/java/com/commafeed/backend/service/db/H2MigrationService.java
+++ b/commafeed-server/src/main/java/com/commafeed/backend/service/db/H2MigrationService.java
@@ -17,6 +17,8 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class H2MigrationService {
+ private static final String H2_FILE_SUFFIX = ".mv.db";
+
public void migrateIfNeeded(Path path, String user, String password) {
if (Files.notExists(path)) {
return;
@@ -54,9 +56,10 @@ public class H2MigrationService {
private void migrate(Path path, String user, String password, String fromVersion, String toVersion) throws Exception {
log.info("migrating H2 database at {} from format {} to format {}", path, fromVersion, toVersion);
- Path scriptPath = path.resolveSibling("script-" + System.currentTimeMillis() + ".sql");
- Path newVersionPath = path.resolveSibling(path.getFileName() + "." + getPatchVersion(toVersion) + ".mv.db");
- Path oldVersionBackupPath = path.resolveSibling(path.getFileName() + "." + getPatchVersion(fromVersion) + ".backup");
+ Path scriptPath = path.resolveSibling("script-%d.sql".formatted(System.currentTimeMillis()));
+ Path newVersionPath = path.resolveSibling("%s.%s%s".formatted(StringUtils.removeEnd(path.getFileName().toString(), H2_FILE_SUFFIX),
+ getPatchVersion(toVersion), H2_FILE_SUFFIX));
+ Path oldVersionBackupPath = path.resolveSibling("%s.%s.backup".formatted(path.getFileName(), getPatchVersion(fromVersion)));
Files.deleteIfExists(scriptPath);
Files.deleteIfExists(newVersionPath);