Introduction
A database migration tool:
- Versions db schema
- Safe, repeatable, ordered migrations
- Apply DB changes automatically (Auto-run on app startup)
- Keep DB schema in sync with code
- Avoid “it works on my machine” DB issues
// like Git for your db schema
Without Flyway ❌:
- Everyone manually runs SQL scripts
- Different devs have different DB versions
- Production DB changes are risky
- Hard to rollback or track changes
How Flyway work:
- SpringBoot app start
- SpringBoot auto-detects Flyway if:
- flyway-core dependency exists
- A DataSource is configured
- Flyway starts migrates DB before hibernate.
- Flyway uses Spring’s DataSource to connect target DB.