fix(flyway): baseline existing schemas at V4 on first run

Local dev databases that existed before Flyway was introduced have tables
but no flyway_schema_history. Flyway refuses to migrate a non-empty schema
without a history table. baselineOnMigrate=true with baselineVersion=4
stamps those databases as already at V4 without re-running migrations.
Fresh databases (CI) have an empty schema so the baseline is never
triggered and all 4 migrations run normally.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-03-18 21:58:54 +01:00
parent a65cbf9bae
commit 6ef7b292cc

View File

@@ -21,6 +21,8 @@ public class FlywayConfig {
Flyway flyway = Flyway.configure()
.dataSource(dataSource)
.locations("classpath:db/migration")
.baselineOnMigrate(true)
.baselineVersion("4")
.load();
var result = flyway.migrate();
log.info("Flyway: {} migration(s) applied.", result.migrationsExecuted);