NIFI-13169 Upgraded Flyway in Registry from 9.22.3 to 10.12.0

This closes #8823

Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
Matt Burgess 2024-05-13 14:31:11 -04:00 committed by exceptionfactory
parent 2a45cae588
commit 08cc23826b
No known key found for this signature in database
4 changed files with 14 additions and 8 deletions

View File

@ -296,6 +296,11 @@
<artifactId>flyway-mysql</artifactId> <artifactId>flyway-mysql</artifactId>
<version>${flyway.version}</version> <version>${flyway.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-database-postgresql</artifactId>
<version>${flyway.version}</version>
</dependency>
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
<artifactId>h2</artifactId> <artifactId>h2</artifactId>

View File

@ -20,10 +20,10 @@ import org.flywaydb.core.api.FlywayException;
import org.flywaydb.core.api.configuration.FluentConfiguration; import org.flywaydb.core.api.configuration.FluentConfiguration;
import org.flywaydb.core.internal.database.DatabaseType; import org.flywaydb.core.internal.database.DatabaseType;
import org.flywaydb.core.internal.database.DatabaseTypeRegister; 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.core.internal.jdbc.JdbcUtils;
import org.flywaydb.database.mysql.MySQLDatabaseType; import org.flywaydb.database.mysql.MySQLDatabaseType;
import org.flywaydb.database.mysql.mariadb.MariaDBDatabaseType; import org.flywaydb.database.mysql.mariadb.MariaDBDatabaseType;
import org.flywaydb.database.postgresql.PostgreSQLDatabaseType;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.flyway.FlywayConfigurationCustomizer; import org.springframework.boot.autoconfigure.flyway.FlywayConfigurationCustomizer;
@ -56,7 +56,7 @@ public class CustomFlywayConfiguration implements FlywayConfigurationCustomizer
@Override @Override
public void customize(final FluentConfiguration configuration) { 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()); LOGGER.info("Determined database type is {}", databaseType.getName());
if (databaseType instanceof MySQLDatabaseType || databaseType instanceof MariaDBDatabaseType) { if (databaseType instanceof MySQLDatabaseType || databaseType instanceof MariaDBDatabaseType) {
@ -87,9 +87,9 @@ public class CustomFlywayConfiguration implements FlywayConfigurationCustomizer
* @param dataSource the data source * @param dataSource the data source
* @return the database type * @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()) { try (final Connection connection = dataSource.getConnection()) {
return DatabaseTypeRegister.getDatabaseTypeForConnection(connection); return DatabaseTypeRegister.getDatabaseTypeForConnection(connection, configuration);
} catch (SQLException e) { } catch (SQLException e) {
LOGGER.error(e.getMessage(), e); LOGGER.error(e.getMessage(), e);
throw new FlywayException("Unable to obtain connection from Flyway DataSource", e); throw new FlywayException("Unable to obtain connection from Flyway DataSource", e);

View File

@ -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.api.UpdateRevisionTask;
import org.apache.nifi.registry.revision.standard.StandardRevisionClaim; import org.apache.nifi.registry.revision.standard.StandardRevisionClaim;
import org.apache.nifi.registry.revision.standard.StandardUpdateResult; 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.DatabaseType;
import org.flywaydb.core.internal.database.DatabaseTypeRegister; import org.flywaydb.core.internal.database.DatabaseTypeRegister;
import org.flywaydb.database.mysql.MySQLDatabaseType; import org.flywaydb.database.mysql.MySQLDatabaseType;
@ -92,11 +93,11 @@ public class TestJdbcRevisionManager {
// Create the REVISION table if it does not exist // Create the REVISION table if it does not exist
final DataSource dataSource = jdbcTemplate.getDataSource(); 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()) { try (final Connection connection = dataSource.getConnection()) {
final String createTableSql; final String createTableSql;
final DatabaseType databaseType = DatabaseTypeRegister.getDatabaseTypeForConnection(connection); final DatabaseType databaseType = DatabaseTypeRegister.getDatabaseTypeForConnection(connection, new FluentConfiguration());
if (databaseType.equals(new MySQLDatabaseType())) { if (databaseType.equals(new MySQLDatabaseType())) {
createTableSql = CREATE_TABLE_SQL_MYSQL; createTableSql = CREATE_TABLE_SQL_MYSQL;
} else { } else {

View File

@ -36,8 +36,8 @@
</modules> </modules>
<properties> <properties>
<spring.boot.version>3.2.5</spring.boot.version> <spring.boot.version>3.2.5</spring.boot.version>
<flyway.version>9.22.3</flyway.version> <flyway.version>10.12.0</flyway.version>
<flyway.tests.version>9.5.0</flyway.tests.version> <flyway.tests.version>10.0.0</flyway.tests.version>
<swagger.ui.version>3.12.0</swagger.ui.version> <swagger.ui.version>3.12.0</swagger.ui.version>
<jgit.version>6.9.0.202403050737-r</jgit.version> <jgit.version>6.9.0.202403050737-r</jgit.version>
<org.apache.sshd.version>2.12.1</org.apache.sshd.version> <org.apache.sshd.version>2.12.1</org.apache.sshd.version>