Skip to content

Commit

Permalink
Merge pull request #16563 from tioback/feature/16561
Browse files Browse the repository at this point in the history
Adds `cleanDisabled` to Flyway configuration
  • Loading branch information
gsmet authored Apr 20, 2021
2 parents 6978921 + 9aa6d6f commit 98bf638
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public Flyway createFlyway(DataSource dataSource) {
if (flywayRuntimeConfig.repeatableSqlMigrationPrefix.isPresent()) {
configure.repeatableSqlMigrationPrefix(flywayRuntimeConfig.repeatableSqlMigrationPrefix.get());
}
configure.cleanDisabled(flywayRuntimeConfig.cleanDisabled);
configure.baselineOnMigrate(flywayRuntimeConfig.baselineOnMigrate);
configure.validateOnMigrate(flywayRuntimeConfig.validateOnMigrate);
configure.ignoreMissingMigrations(flywayRuntimeConfig.ignoreMissingMigrations);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ public static final FlywayDataSourceRuntimeConfig defaultConfig() {
@ConfigItem
public boolean cleanAtStart;

/**
* true to prevent Flyway clean operations, false otherwise.
*/
@ConfigItem
public boolean cleanDisabled;

/**
* true to execute Flyway automatically when the application starts, false otherwise.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,22 @@ void testValidateOnMigrate() {
assertTrue(runtimeConfig.validateOnMigrate);
}

@Test
@DisplayName("clean disabled default matches to false")
void testCleanDisabled() {
creator = new FlywayCreator(runtimeConfig, buildConfig);
assertEquals(runtimeConfig.cleanDisabled, createdFlywayConfig().isCleanDisabled());
assertFalse(runtimeConfig.cleanDisabled);

runtimeConfig.cleanDisabled = false;
creator = new FlywayCreator(runtimeConfig, buildConfig);
assertFalse(createdFlywayConfig().isCleanDisabled());

runtimeConfig.cleanDisabled = true;
creator = new FlywayCreator(runtimeConfig, buildConfig);
assertTrue(createdFlywayConfig().isCleanDisabled());
}

@Test
@DisplayName("outOfOrder is correctly set")
void testOutOfOrder() {
Expand Down

0 comments on commit 98bf638

Please sign in to comment.