Reputation: 643
I have a Maven multi-module Spring Boot project with modules App, Domain1 and Domain2. App depends on Domain1 and Domain2.
Flyway is auto configured in the App module, with migrations in db/migrations. It runs without problems.
In the domain modules, I have AutoConfiguration classes with @AutoConfigureBefore(JpaAutoConfiguration::class)
to run flyway manually 'per domain'. Each domain has it's migration files in different locations (to prevent collissions):
Domain1:
@Autowired
fun migrateFlyway(dataSource: DataSource) {
val cfg = FluentConfiguration()
.locations("classpath:migrations/domain1")
.baselineOnMigrate(true)
.table("flyway_domain1_history")
.dataSource(dataSource)
val flyway = Flyway(cfg)
flyway.migrate()
}
Domain2:
@Autowired
fun migrateFlyway(dataSource: DataSource) {
val cfg = FluentConfiguration()
.locations("classpath:migrations/domain2")
.baselineOnMigrate(true)
.table("flyway_domain2_history")
.dataSource(dataSource)
val flyway = Flyway(cfg)
flyway.migrate()
}
The problem is: both flyway instances from the domain run, creating their respective history tables. However: neither of them actually executes the sql files in them, although they exist (checked from IntelliJ in the target folder, and after building the whole thing with Maven, the SQL files exist in the JAR's).
Am I missing something?
Upvotes: 1
Views: 1156
Reputation: 643
Never mind, after years of using Flyway I just didn't understand the baseline property. De default is 1, and my first script has version 1. So Flyway saw it, but skipped. Setting baseline to '000' solved the problem.
Upvotes: 0