Skip to content

Commit

Permalink
Adds cleanDisabled to Flyway configuration. Fixes quarkusio#16561.
Browse files Browse the repository at this point in the history
(cherry picked from commit 9aa6d6f)
  • Loading branch information
tioback authored and gsmet committed Apr 26, 2021
1 parent b5aff86 commit 6eae216
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 6eae216

Please sign in to comment.