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 d7b1ac76f7a96..779b5394279bf 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 @@ -59,7 +59,7 @@ public Flyway createFlyway(DataSource dataSource) { configure.cleanDisabled(flywayRuntimeConfig.cleanDisabled); configure.baselineOnMigrate(flywayRuntimeConfig.baselineOnMigrate); configure.validateOnMigrate(flywayRuntimeConfig.validateOnMigrate); - configure.validateMigrationNaming(true); + configure.validateMigrationNaming(flywayRuntimeConfig.validateMigrationNaming); List patterns = new ArrayList<>(2); //https://flywaydb.org/documentation/configuration/parameters/ignoreMigrationPatterns if (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 1b49e442622c0..721093f336099 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 @@ -180,4 +180,11 @@ public static final FlywayDataSourceRuntimeConfig defaultConfig() { */ @ConfigItem public Optional initSql = Optional.empty(); + + /** + * Whether to validate migrations and callbacks whose scripts do not obey the correct naming convention. A failure can be + * useful to check that errors such as case sensitivity in migration prefixes have been corrected. + */ + @ConfigItem + public boolean validateMigrationNaming; } 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 73a5d47524204..21decf5b03779 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 @@ -246,6 +246,18 @@ void testValidateOnMigrateOverwritten(final boolean input, final boolean expecte assertEquals(runtimeConfig.validateOnMigrate, expected); } + @Test + @DisplayName("validateMigrationNaming defaults to false and it is correctly set") + void testValidateMigrationNaming() { + creator = new FlywayCreator(runtimeConfig, buildConfig); + assertEquals(runtimeConfig.validateMigrationNaming, createdFlywayConfig().isValidateMigrationNaming()); + assertFalse(runtimeConfig.validateMigrationNaming); + + runtimeConfig.validateMigrationNaming = true; + creator = new FlywayCreator(runtimeConfig, buildConfig); + assertTrue(createdFlywayConfig().isValidateMigrationNaming()); + } + private static List pathList(Location[] locations) { return Stream.of(locations).map(Location::getPath).collect(Collectors.toList()); }