From 08cc23826ba2f4c83848d9eefbf69193d8c10b29 Mon Sep 17 00:00:00 2001 From: Matt Burgess Date: Mon, 13 May 2024 14:31:11 -0400 Subject: [PATCH] NIFI-13169 Upgraded Flyway in Registry from 9.22.3 to 10.12.0 This closes #8823 Signed-off-by: David Handermann --- .../nifi-registry-core/nifi-registry-framework/pom.xml | 5 +++++ .../nifi/registry/db/CustomFlywayConfiguration.java | 8 ++++---- .../registry/revision/jdbc/TestJdbcRevisionManager.java | 5 +++-- nifi-registry/pom.xml | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/pom.xml b/nifi-registry/nifi-registry-core/nifi-registry-framework/pom.xml index a1afec44d5..b4580e1861 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/pom.xml +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/pom.xml @@ -296,6 +296,11 @@ flyway-mysql ${flyway.version} + + org.flywaydb + flyway-database-postgresql + ${flyway.version} + com.h2database h2 diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/db/CustomFlywayConfiguration.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/db/CustomFlywayConfiguration.java index 42e2946b70..d21046f9bd 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/db/CustomFlywayConfiguration.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/db/CustomFlywayConfiguration.java @@ -20,10 +20,10 @@ import org.flywaydb.core.api.FlywayException; import org.flywaydb.core.api.configuration.FluentConfiguration; import org.flywaydb.core.internal.database.DatabaseType; import org.flywaydb.core.internal.database.DatabaseTypeRegister; -import org.flywaydb.core.internal.database.postgresql.PostgreSQLDatabaseType; import org.flywaydb.core.internal.jdbc.JdbcUtils; import org.flywaydb.database.mysql.MySQLDatabaseType; import org.flywaydb.database.mysql.mariadb.MariaDBDatabaseType; +import org.flywaydb.database.postgresql.PostgreSQLDatabaseType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.flyway.FlywayConfigurationCustomizer; @@ -56,7 +56,7 @@ public class CustomFlywayConfiguration implements FlywayConfigurationCustomizer @Override public void customize(final FluentConfiguration configuration) { - final DatabaseType databaseType = getDatabaseType(configuration.getDataSource()); + final DatabaseType databaseType = getDatabaseType(configuration.getDataSource(), configuration); LOGGER.info("Determined database type is {}", databaseType.getName()); if (databaseType instanceof MySQLDatabaseType || databaseType instanceof MariaDBDatabaseType) { @@ -87,9 +87,9 @@ public class CustomFlywayConfiguration implements FlywayConfigurationCustomizer * @param dataSource the data source * @return the database type */ - private DatabaseType getDatabaseType(final DataSource dataSource) { + private DatabaseType getDatabaseType(final DataSource dataSource, final org.flywaydb.core.api.configuration.Configuration configuration) { try (final Connection connection = dataSource.getConnection()) { - return DatabaseTypeRegister.getDatabaseTypeForConnection(connection); + return DatabaseTypeRegister.getDatabaseTypeForConnection(connection, configuration); } catch (SQLException e) { LOGGER.error(e.getMessage(), e); throw new FlywayException("Unable to obtain connection from Flyway DataSource", e); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-revision/nifi-registry-revision-spring-jdbc/src/test/java/org/apache/nifi/registry/revision/jdbc/TestJdbcRevisionManager.java b/nifi-registry/nifi-registry-core/nifi-registry-revision/nifi-registry-revision-spring-jdbc/src/test/java/org/apache/nifi/registry/revision/jdbc/TestJdbcRevisionManager.java index 4af747dc03..5d3d23949e 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-revision/nifi-registry-revision-spring-jdbc/src/test/java/org/apache/nifi/registry/revision/jdbc/TestJdbcRevisionManager.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-revision/nifi-registry-revision-spring-jdbc/src/test/java/org/apache/nifi/registry/revision/jdbc/TestJdbcRevisionManager.java @@ -27,6 +27,7 @@ import org.apache.nifi.registry.revision.api.RevisionUpdate; import org.apache.nifi.registry.revision.api.UpdateRevisionTask; import org.apache.nifi.registry.revision.standard.StandardRevisionClaim; import org.apache.nifi.registry.revision.standard.StandardUpdateResult; +import org.flywaydb.core.api.configuration.FluentConfiguration; import org.flywaydb.core.internal.database.DatabaseType; import org.flywaydb.core.internal.database.DatabaseTypeRegister; import org.flywaydb.database.mysql.MySQLDatabaseType; @@ -92,11 +93,11 @@ public class TestJdbcRevisionManager { // Create the REVISION table if it does not exist final DataSource dataSource = jdbcTemplate.getDataSource(); - LOGGER.info("#### DataSource class is {}", new Object[]{dataSource.getClass().getCanonicalName()}); + LOGGER.info("#### DataSource class is {}", dataSource.getClass().getCanonicalName()); try (final Connection connection = dataSource.getConnection()) { final String createTableSql; - final DatabaseType databaseType = DatabaseTypeRegister.getDatabaseTypeForConnection(connection); + final DatabaseType databaseType = DatabaseTypeRegister.getDatabaseTypeForConnection(connection, new FluentConfiguration()); if (databaseType.equals(new MySQLDatabaseType())) { createTableSql = CREATE_TABLE_SQL_MYSQL; } else { diff --git a/nifi-registry/pom.xml b/nifi-registry/pom.xml index be7e62e0a9..63353a3b9b 100644 --- a/nifi-registry/pom.xml +++ b/nifi-registry/pom.xml @@ -36,8 +36,8 @@ 3.2.5 - 9.22.3 - 9.5.0 + 10.12.0 + 10.0.0 3.12.0 6.9.0.202403050737-r 2.12.1