Skip to content

Commit

Permalink
NIFI-13169: Upgrade Flyway in Registry to 10.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyb149 committed May 13, 2024
1 parent 13e281d commit b062507
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@
<artifactId>flyway-mysql</artifactId>
<version>${flyway.version}</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-database-postgresql</artifactId>
<version>${flyway.version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -87,9 +87,9 @@ public void customize(final FluentConfiguration configuration) {
* @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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
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;
Expand Down Expand Up @@ -92,11 +93,11 @@ public void setup() throws SQLException {

// 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 {
Expand Down
4 changes: 2 additions & 2 deletions nifi-registry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
</modules>
<properties>
<spring.boot.version>3.2.5</spring.boot.version>
<flyway.version>9.22.3</flyway.version>
<flyway.tests.version>9.5.0</flyway.tests.version>
<flyway.version>10.12.0</flyway.version>
<flyway.tests.version>10.0.0</flyway.tests.version>
<swagger.ui.version>3.12.0</swagger.ui.version>
<jgit.version>6.9.0.202403050737-r</jgit.version>
<org.apache.sshd.version>2.12.1</org.apache.sshd.version>
Expand Down

0 comments on commit b062507

Please sign in to comment.