diff --git a/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayCreator.java b/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayCreator.java index 5602b767ec837..d1df4c3f7c435 100644 --- a/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayCreator.java +++ b/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayCreator.java @@ -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); diff --git a/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayDataSourceRuntimeConfig.java b/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayDataSourceRuntimeConfig.java index 50c23a5118224..ba121db50e010 100644 --- a/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayDataSourceRuntimeConfig.java +++ b/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayDataSourceRuntimeConfig.java @@ -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. * diff --git a/extensions/flyway/runtime/src/test/java/io/quarkus/flyway/runtime/FlywayCreatorTest.java b/extensions/flyway/runtime/src/test/java/io/quarkus/flyway/runtime/FlywayCreatorTest.java index 23c1e37524068..a4635481b29d1 100644 --- a/extensions/flyway/runtime/src/test/java/io/quarkus/flyway/runtime/FlywayCreatorTest.java +++ b/extensions/flyway/runtime/src/test/java/io/quarkus/flyway/runtime/FlywayCreatorTest.java @@ -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() {