Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
update flyway version (#2065)
Browse files Browse the repository at this point in the history
* update flyway version

* set FLYWAY_TABLE_DEFAULT_VALUE to schema_history

* update flyway version

Co-authored-by: michaelpa <michael.paliy@niceactimize.com>
  • Loading branch information
michaelpaliy and michaelpaliy committed Apr 5, 2021
1 parent 216960d commit dabbacc
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 90 deletions.
36 changes: 18 additions & 18 deletions mysql-persistence/dependencies.lock
Expand Up @@ -232,8 +232,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down Expand Up @@ -498,8 +498,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down Expand Up @@ -764,8 +764,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down Expand Up @@ -1093,8 +1093,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down Expand Up @@ -1359,8 +1359,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down Expand Up @@ -1662,8 +1662,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down Expand Up @@ -2085,8 +2085,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down Expand Up @@ -2508,8 +2508,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down Expand Up @@ -2931,8 +2931,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down
Expand Up @@ -2,7 +2,7 @@

import com.netflix.conductor.core.config.Configuration;

import java.util.Optional;

import java.util.concurrent.TimeUnit;

public interface MySQLConfiguration extends Configuration {
Expand All @@ -20,7 +20,7 @@ public interface MySQLConfiguration extends Configuration {
boolean FLYWAY_ENABLED_DEFAULT_VALUE = true;

String FLYWAY_TABLE_PROPERTY_NAME = "flyway.table";
Optional<String> FLYWAY_TABLE_DEFAULT_VALUE = Optional.empty();
String FLYWAY_TABLE_DEFAULT_VALUE = "schema_version";

// The defaults are currently in line with the HikariConfig defaults, which are unfortunately private.
String CONNECTION_POOL_MAX_SIZE_PROPERTY_NAME = "conductor.mysql.connection.pool.size.max";
Expand Down Expand Up @@ -61,8 +61,8 @@ default boolean isFlywayEnabled() {
return getBoolProperty(FLYWAY_ENABLED_PROPERTY_NAME, FLYWAY_ENABLED_DEFAULT_VALUE);
}

default Optional<String> getFlywayTable() {
return Optional.ofNullable(getProperty(FLYWAY_TABLE_PROPERTY_NAME, null));
default String getFlywayTable() {
return getProperty(FLYWAY_TABLE_PROPERTY_NAME, FLYWAY_TABLE_DEFAULT_VALUE);
}

default int getConnectionPoolMaxSize() {
Expand Down
Expand Up @@ -4,6 +4,7 @@
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.configuration.FluentConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -67,16 +68,15 @@ private void flywayMigrate(DataSource dataSource) {
logger.debug("Flyway migrations are disabled");
return;
}
String flywayTable = configuration.getFlywayTable();
logger.debug("Using Flyway migration table '{}'", flywayTable);

FluentConfiguration flywayConfiguration = Flyway.configure()
.table(flywayTable)
.dataSource(dataSource)
.placeholderReplacement(false);

Flyway flyway = new Flyway();
configuration.getFlywayTable().ifPresent(tableName -> {
logger.debug("Using Flyway migration table '{}'", tableName);
flyway.setTable(tableName);
});

flyway.setDataSource(dataSource);
flyway.setPlaceholderReplacement(false);
Flyway flyway = flywayConfiguration.load();
flyway.migrate();
}
}
Expand Up @@ -72,9 +72,12 @@ private HikariDataSource getDataSource(Configuration config) {

private void flywayMigrate(DataSource dataSource) {

Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setPlaceholderReplacement(false);
Flyway flyway = Flyway.configure()
.dataSource(dataSource)
.table("schema_version")
.placeholderReplacement(false)
.load();

flyway.migrate();
}

Expand Down
36 changes: 18 additions & 18 deletions postgres-persistence/dependencies.lock
Expand Up @@ -227,8 +227,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down Expand Up @@ -492,8 +492,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down Expand Up @@ -757,8 +757,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down Expand Up @@ -1085,8 +1085,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down Expand Up @@ -1350,8 +1350,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down Expand Up @@ -1652,8 +1652,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down Expand Up @@ -2074,8 +2074,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down Expand Up @@ -2496,8 +2496,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down Expand Up @@ -2918,8 +2918,8 @@
]
},
"org.flywaydb:flyway-core": {
"locked": "4.0.3",
"requested": "4.0.3"
"locked": "7.5.2",
"requested": "7.5.2"
},
"org.glassfish:javax.el": {
"locked": "3.0.0",
Expand Down
Expand Up @@ -14,7 +14,6 @@

import com.netflix.conductor.core.config.Configuration;

import java.util.Optional;
import java.util.concurrent.TimeUnit;

public interface PostgresConfiguration extends Configuration {
Expand All @@ -32,7 +31,7 @@ public interface PostgresConfiguration extends Configuration {
boolean FLYWAY_ENABLED_DEFAULT_VALUE = true;

String FLYWAY_TABLE_PROPERTY_NAME = "flyway.table";
Optional<String> FLYWAY_TABLE_DEFAULT_VALUE = Optional.empty();
String FLYWAY_TABLE_DEFAULT_VALUE = "schema_version";

// The defaults are currently in line with the HikariConfig defaults, which are unfortunately private.
String CONNECTION_POOL_MAX_SIZE_PROPERTY_NAME = "conductor.postgres.connection.pool.size.max";
Expand Down Expand Up @@ -73,8 +72,8 @@ default boolean isFlywayEnabled() {
return getBoolProperty(FLYWAY_ENABLED_PROPERTY_NAME, FLYWAY_ENABLED_DEFAULT_VALUE);
}

default Optional<String> getFlywayTable() {
return Optional.ofNullable(getProperty(FLYWAY_TABLE_PROPERTY_NAME, null));
default String getFlywayTable() {
return getProperty(FLYWAY_TABLE_PROPERTY_NAME, FLYWAY_TABLE_DEFAULT_VALUE);
}

default int getConnectionPoolMaxSize() {
Expand Down
Expand Up @@ -16,6 +16,7 @@
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.configuration.FluentConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -80,17 +81,16 @@ private void flywayMigrate(DataSource dataSource) {
logger.debug("Flyway migrations are disabled");
return;
}
String flywayTable = configuration.getFlywayTable();
logger.debug("Using Flyway migration table '{}'", flywayTable);

FluentConfiguration flywayConfiguration = Flyway.configure()
.table(flywayTable)
.locations(Paths.get("db","migration_postgres").toString())
.dataSource(dataSource)
.placeholderReplacement(false);

Flyway flyway = new Flyway();
configuration.getFlywayTable().ifPresent(tableName -> {
logger.debug("Using Flyway migration table '{}'", tableName);
flyway.setTable(tableName);
});

flyway.setLocations(Paths.get("db","migration_postgres").toString());
flyway.setDataSource(dataSource);
flyway.setPlaceholderReplacement(false);
Flyway flyway = flywayConfiguration.load();
flyway.migrate();
}
}
Expand Up @@ -18,6 +18,7 @@
import com.netflix.conductor.core.config.Configuration;
import com.zaxxer.hikari.HikariDataSource;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.configuration.FluentConfiguration;
import org.postgresql.ds.PGSimpleDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -74,11 +75,15 @@ private HikariDataSource getDataSource(Configuration config) {

private void flywayMigrate(DataSource dataSource) {

Flyway flyway = new Flyway();
flyway.setLocations(Paths.get("db","migration_postgres").toString());
flyway.setDataSource(dataSource);
flyway.setPlaceholderReplacement(false);
FluentConfiguration flywayConfiguration = Flyway.configure()
.table("schema_version")
.locations(Paths.get("db","migration_postgres").toString())
.dataSource(dataSource)
.placeholderReplacement(false);

Flyway flyway = flywayConfiguration.load();
flyway.migrate();

}

public HikariDataSource getDataSource() {
Expand Down
Expand Up @@ -36,6 +36,7 @@
import javax.sql.DataSource;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.FlywayException;
import org.flywaydb.core.api.configuration.FluentConfiguration;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
Expand Down Expand Up @@ -447,10 +448,15 @@ private List<Message> getRandomMessages(int i) {
}

private void flywayMigrate(DataSource dataSource) {
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setPlaceholderReplacement(false);
flyway.setLocations(Paths.get("db", "migration_postgres").toString());

FluentConfiguration flywayConfiguration = Flyway.configure()
.table(configuration.getFlywayTable())
.locations(Paths.get("db","migration_postgres").toString())
.dataSource(dataSource)
.placeholderReplacement(false);

Flyway flyway = flywayConfiguration.load();

try {
flyway.migrate();
} catch (FlywayException e) {
Expand Down

0 comments on commit dabbacc

Please sign in to comment.