I have a project with ~20 modules, of which some represent just infrastructure or contain types that are being used by other modules. These define no persistent types and require no Flyway migration. When running Flyway with per-module migration scripts, this turns out to be really slow, as Flyway is creating the history table and checking for migration scripts when there is really nothing to do.
Eventually modulith runtime could check if
- a module has migration scripts a
- a module has entities
and only then invoke the flyway migration.
I looked into tweaking SpringModulithFlywayAutoConfiguration
@AutoConfiguration
@ConditionalOnClass({ Flyway.class, FlywayMigrationStrategy.class })
static class SpringModulithFlywayAutoConfiguration {
@Bean
@ConditionalOnProperty(name = "spring.modulith.runtime.flyway-enabled", havingValue = "true")
SpringModulithFlywayMigrationStrategy springModulithFlywayMigrationStrategy(
ApplicationModuleIdentifiers identifiers, BeanFactory factory) {
var filter = new ModuleFilter(factory);
var filtered = ApplicationModuleIdentifiers.of(identifiers.stream().filter(filter).toList());
return new SpringModulithFlywayMigrationStrategy(filtered);
}
}
However, as ModuleFilter is not a public API, it's a bit difficult to replace the springModulithFlywayMigrationStrategy bean with a custom one.
I have a project with ~20 modules, of which some represent just infrastructure or contain types that are being used by other modules. These define no persistent types and require no Flyway migration. When running Flyway with per-module migration scripts, this turns out to be really slow, as Flyway is creating the history table and checking for migration scripts when there is really nothing to do.
Eventually modulith runtime could check if
and only then invoke the flyway migration.
I looked into tweaking SpringModulithFlywayAutoConfiguration
However, as
ModuleFilteris not a public API, it's a bit difficult to replace the springModulithFlywayMigrationStrategy bean with a custom one.