From b66a38da47be67f372b6a6d5e236ecf27914ee94 Mon Sep 17 00:00:00 2001 From: Glaucio Jannotti Date: Wed, 3 Jul 2024 11:50:01 -0300 Subject: [PATCH] fix: flyway migrations conflict --- build.gradle.kts | 2 +- .../logginghouse/client/ConfigConstants.java | 14 +++++++------- .../client/LoggingHouseClientExtension.java | 12 ++++++------ .../logginghouse/client/flyway/FlywayService.java | 2 +- .../flyway/connection/DatasourceProperties.java | 9 +-------- .../flyway/migration/DatabaseMigrationManager.java | 2 +- .../{ => logginghouse}/V0_0_1__Create_Tables.sql | 0 7 files changed, 17 insertions(+), 24 deletions(-) rename logging-house-client/src/main/resources/migration/{ => logginghouse}/V0_0_1__Create_Tables.sql (100%) diff --git a/build.gradle.kts b/build.gradle.kts index 3aae426..7be6075 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -62,7 +62,7 @@ subprojects { maven { name = "GitHubPackages" url = uri("https://maven.pkg.github.com/truzzt/mds-ap3") - version = "0.3.0" + version = "0.3.1" credentials { username = System.getenv("USERNAME") password = System.getenv("TOKEN") diff --git a/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/ConfigConstants.java b/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/ConfigConstants.java index c2d4477..cac20f4 100644 --- a/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/ConfigConstants.java +++ b/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/ConfigConstants.java @@ -16,17 +16,17 @@ public class ConfigConstants { - static final String LOGGINGHOUSE_ENABLED = "edc.logginghouse.client.enabled"; + static final String LOGGINGHOUSE_ENABLED_SETTING = "edc.logginghouse.extension.enabled"; - static final String LOGGINGHOUSE_SERVER_URL_SETTING = "edc.logginghouse.client.server.url"; + static final String LOGGINGHOUSE_URL_SETTING = "edc.logginghouse.extension.url"; - static final String LOGGINGHOUSE_FLYWAY_REPAIR_SETTING = "edc.logginghouse.client.flyway.repair"; + static final String LOGGINGHOUSE_FLYWAY_REPAIR_SETTING = "edc.logginghouse.extension.flyway.repair"; - static final String LOGGINGHOUSE_FLYWAY_CLEAN_SETTING = "edc.logginghouse.client.flyway.clean"; + static final String LOGGINGHOUSE_FLYWAY_CLEAN_SETTING = "edc.logginghouse.extension.flyway.clean"; - static final String LOGGINGHOUSE_EXTENSION_MAX_WORKERS = "edc.logginghouse.client.workers.max"; + static final String LOGGINGHOUSE_EXTENSION_MAX_WORKERS = "edc.logginghouse.extension.workers.max"; - static final String LOGGINGHOUSE_EXTENSION_WORKERS_DELAY = "edc.logginghouse.client.workers.delay"; + static final String LOGGINGHOUSE_EXTENSION_WORKERS_DELAY = "edc.logginghouse.extension.workers.delay"; - static final String LOGGINGHOUSE_EXTENSION_WORKERS_PERIOD = "edc.logginghouse.client.workers.period"; + static final String LOGGINGHOUSE_EXTENSION_WORKERS_PERIOD = "edc.logginghouse.extension.workers.period"; } diff --git a/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/LoggingHouseClientExtension.java b/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/LoggingHouseClientExtension.java index 82efc7a..b5c8e8b 100644 --- a/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/LoggingHouseClientExtension.java +++ b/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/LoggingHouseClientExtension.java @@ -63,13 +63,13 @@ import java.time.Duration; import java.util.Map; -import static com.truzzt.extension.logginghouse.client.ConfigConstants.LOGGINGHOUSE_ENABLED; +import static com.truzzt.extension.logginghouse.client.ConfigConstants.LOGGINGHOUSE_ENABLED_SETTING; import static com.truzzt.extension.logginghouse.client.ConfigConstants.LOGGINGHOUSE_EXTENSION_MAX_WORKERS; import static com.truzzt.extension.logginghouse.client.ConfigConstants.LOGGINGHOUSE_EXTENSION_WORKERS_DELAY; import static com.truzzt.extension.logginghouse.client.ConfigConstants.LOGGINGHOUSE_EXTENSION_WORKERS_PERIOD; import static com.truzzt.extension.logginghouse.client.ConfigConstants.LOGGINGHOUSE_FLYWAY_CLEAN_SETTING; import static com.truzzt.extension.logginghouse.client.ConfigConstants.LOGGINGHOUSE_FLYWAY_REPAIR_SETTING; -import static com.truzzt.extension.logginghouse.client.ConfigConstants.LOGGINGHOUSE_SERVER_URL_SETTING; +import static com.truzzt.extension.logginghouse.client.ConfigConstants.LOGGINGHOUSE_URL_SETTING; @Extension(value = LoggingHouseClientExtension.NAME) @Requires(value = { @@ -137,7 +137,7 @@ public String name() { public void initialize(ServiceExtensionContext context) { monitor = context.getMonitor(); - var extensionEnabled = context.getSetting(LOGGINGHOUSE_ENABLED, true); + var extensionEnabled = context.getSetting(LOGGINGHOUSE_ENABLED_SETTING, true); if (!extensionEnabled) { enabled = false; monitor.info("Logginghouse client extension is disabled."); @@ -161,16 +161,16 @@ public void initialize(ServiceExtensionContext context) { private URL readUrlFromSettings(ServiceExtensionContext context) { try { - var urlString = context.getSetting(LOGGINGHOUSE_SERVER_URL_SETTING, null); + var urlString = context.getSetting(LOGGINGHOUSE_URL_SETTING, null); if (urlString == null) { throw new EdcException(String.format("Could not initialize LoggingHouseClientExtension: " + - "No url specified using setting %s", LOGGINGHOUSE_SERVER_URL_SETTING)); + "No url specified using setting %s", LOGGINGHOUSE_URL_SETTING)); } return new URL(urlString); } catch (MalformedURLException e) { throw new EdcException(String.format("Could not parse setting %s to Url", - LOGGINGHOUSE_SERVER_URL_SETTING), e); + LOGGINGHOUSE_URL_SETTING), e); } } diff --git a/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/flyway/FlywayService.java b/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/flyway/FlywayService.java index 4863dd9..8a8f9c4 100644 --- a/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/flyway/FlywayService.java +++ b/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/flyway/FlywayService.java @@ -30,7 +30,7 @@ public class FlywayService { - private static final String MIGRATION_LOCATION_BASE = "classpath:migration"; + private static final String MIGRATION_LOCATION_BASE = "classpath:migration/logginghouse"; private static final String MIGRATION_TABLE_NAME = "flyway_schema_history_logginghouse"; private final Monitor monitor; diff --git a/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/flyway/connection/DatasourceProperties.java b/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/flyway/connection/DatasourceProperties.java index 543eac3..59c1ddc 100644 --- a/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/flyway/connection/DatasourceProperties.java +++ b/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/flyway/connection/DatasourceProperties.java @@ -19,27 +19,20 @@ public class DatasourceProperties { public static final String LOGGING_HOUSE_DATASOURCE = "logginghouse"; - private static final String DATASOURCE_SETTING_NAME = "edc.datasource.logginghouse.name"; private static final String DATASOURCE_SETTING_JDBC_URL = "edc.datasource.logginghouse.url"; private static final String DATASOURCE_SETTING_USER = "edc.datasource.logginghouse.user"; private static final String DATASOURCE_SETTING_PASSWORD = "edc.datasource.logginghouse.password"; - - private final String name; + private final String jdbcUrl; private final String user; private final String password; public DatasourceProperties(Config config) { - name = config.getString(DATASOURCE_SETTING_NAME); jdbcUrl = config.getString(DATASOURCE_SETTING_JDBC_URL); user = config.getString(DATASOURCE_SETTING_USER); password = config.getString(DATASOURCE_SETTING_PASSWORD); } - public String getName() { - return name; - } - public String getJdbcUrl() { return jdbcUrl; } diff --git a/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/flyway/migration/DatabaseMigrationManager.java b/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/flyway/migration/DatabaseMigrationManager.java index 81aab02..416a082 100644 --- a/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/flyway/migration/DatabaseMigrationManager.java +++ b/logging-house-client/src/main/java/com/truzzt/extension/logginghouse/client/flyway/migration/DatabaseMigrationManager.java @@ -32,7 +32,7 @@ public DatabaseMigrationManager(Config config, Monitor monitor, FlywayService fl public void migrate() { var datasourceProperties = new DatasourceProperties(config); - monitor.info("Using datasource %s to apply flyway migrations".formatted(datasourceProperties.getName())); + monitor.info("Using datasource %s to apply flyway migrations".formatted(DatasourceProperties.LOGGING_HOUSE_DATASOURCE)); flywayService.cleanDatabase(datasourceProperties); flywayService.migrateDatabase(datasourceProperties); diff --git a/logging-house-client/src/main/resources/migration/V0_0_1__Create_Tables.sql b/logging-house-client/src/main/resources/migration/logginghouse/V0_0_1__Create_Tables.sql similarity index 100% rename from logging-house-client/src/main/resources/migration/V0_0_1__Create_Tables.sql rename to logging-house-client/src/main/resources/migration/logginghouse/V0_0_1__Create_Tables.sql