Skip to content

Commit

Permalink
Introduce validateMigrationNaming
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Aug 2, 2022
1 parent b0bb48e commit 790c55f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> patterns = new ArrayList<>(2);
//https://flywaydb.org/documentation/configuration/parameters/ignoreMigrationPatterns
if (flywayRuntimeConfig.ignoreMissingMigrations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,11 @@ public static final FlywayDataSourceRuntimeConfig defaultConfig() {
*/
@ConfigItem
public Optional<String> 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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> pathList(Location[] locations) {
return Stream.of(locations).map(Location::getPath).collect(Collectors.toList());
}
Expand Down

0 comments on commit 790c55f

Please sign in to comment.