Skip to content

Commit

Permalink
Support Flyway ignoreMissingMigrations config
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Aug 18, 2020
1 parent 0c4ac13 commit 6b4973d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public Flyway createFlyway(DataSource dataSource) {
}
configure.baselineOnMigrate(flywayRuntimeConfig.baselineOnMigrate);
configure.validateOnMigrate(flywayRuntimeConfig.validateOnMigrate);
configure.ignoreMissingMigrations(flywayRuntimeConfig.ignoreMissingMigrations);
configure.outOfOrder(flywayRuntimeConfig.outOfOrder);
if (flywayRuntimeConfig.baselineVersion.isPresent()) {
configure.baselineVersion(flywayRuntimeConfig.baselineVersion.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ public static final FlywayDataSourceRuntimeConfig defaultConfig() {
@ConfigItem
public boolean outOfOrder;

/**
* Ignore missing migrations when reading the history table. When set to true any migration present in the history table but
* absent in the configured locations will be ignored (and logged as a warning), when false (the default) the validation
* step
* will fail.
*/
@ConfigItem
public boolean ignoreMissingMigrations;

/**
* Sets the placeholders to replace in SQL migration scripts.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void testValidateOnMigrate() {

@Test
@DisplayName("outOfOrder is correctly set")
void testOutOfOrder() {
void testIgnoreMissing() {
runtimeConfig.outOfOrder = false;
creator = new FlywayCreator(runtimeConfig, buildConfig);
assertFalse(createdFlywayConfig().isOutOfOrder());
Expand All @@ -179,6 +179,18 @@ void testOutOfOrder() {
assertTrue(createdFlywayConfig().isOutOfOrder());
}

@Test
@DisplayName("ignoreMissingMigrations is correctly set")
void testOutOfOrder() {
runtimeConfig.ignoreMissingMigrations = false;
creator = new FlywayCreator(runtimeConfig, buildConfig);
assertFalse(createdFlywayConfig().isIgnoreMissingMigrations());

runtimeConfig.ignoreMissingMigrations = true;
creator = new FlywayCreator(runtimeConfig, buildConfig);
assertTrue(createdFlywayConfig().isIgnoreMissingMigrations());
}

@ParameterizedTest
@MethodSource("validateOnMigrateOverwritten")
@DisplayName("validate on migrate overwritten in configuration")
Expand Down

0 comments on commit 6b4973d

Please sign in to comment.