Make FlywayMigrationStrategy an interface
Change FlywayMigrationStrategy from a class to an interface. Fixes gh-3217
This commit is contained in:
parent
134bc02404
commit
4236a9336d
|
|
@ -75,6 +75,9 @@ public class FlywayAutoConfiguration {
|
|||
@FlywayDataSource
|
||||
private DataSource flywayDataSource;
|
||||
|
||||
@Autowired(required = false)
|
||||
private FlywayMigrationStrategy migrationStrategy;
|
||||
|
||||
@PostConstruct
|
||||
public void checkLocationExists() {
|
||||
if (this.properties.isCheckLocation()) {
|
||||
|
|
@ -96,12 +99,6 @@ public class FlywayAutoConfiguration {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public FlywayMigrationStrategy flywayMigrationStrategy() {
|
||||
return new FlywayMigrationStrategy();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "flyway")
|
||||
public Flyway flyway() {
|
||||
|
|
@ -121,9 +118,8 @@ public class FlywayAutoConfiguration {
|
|||
}
|
||||
|
||||
@Bean
|
||||
public FlywayMigrationInitializer flywayInitializer(Flyway flyway,
|
||||
FlywayMigrationStrategy migrationStrategy) {
|
||||
return new FlywayMigrationInitializer(flyway, migrationStrategy);
|
||||
public FlywayMigrationInitializer flywayInitializer(Flyway flyway) {
|
||||
return new FlywayMigrationInitializer(flyway, this.migrationStrategy);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -163,8 +159,13 @@ public class FlywayAutoConfiguration {
|
|||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
if (this.migrationStrategy != null) {
|
||||
this.migrationStrategy.migrate(this.flyway);
|
||||
}
|
||||
else {
|
||||
this.flyway.migrate();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,10 +25,12 @@ import org.flywaydb.core.Flyway;
|
|||
* @author Andreas Ahlenstorf
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class FlywayMigrationStrategy {
|
||||
public interface FlywayMigrationStrategy {
|
||||
|
||||
public void migrate(Flyway flyway) {
|
||||
flyway.migrate();
|
||||
}
|
||||
/**
|
||||
* Trigger flyway migration.
|
||||
* @param flyway the flyway instance
|
||||
*/
|
||||
void migrate(Flyway flyway);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ public class FlywayAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Component
|
||||
protected static class MockFlywayMigrationStrategy extends FlywayMigrationStrategy {
|
||||
protected static class MockFlywayMigrationStrategy implements FlywayMigrationStrategy {
|
||||
|
||||
private boolean called = false;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue