Guide Flyway database migrations in Spring Boot including naming conventions, versioning strategy, safe migration patterns, module-aware migrations, and troubleshooting. Use when creating or managing database schema migrations.
Conventions for managing database schema migrations with Flyway in Spring Boot 3.2+.
Do NOT Load for Liquibase or manual schema management — this skill is Flyway-specific.
V<version>__<description>.sql
│ │ │
│ │ └── Snake_case description (double underscore separator)
│ └── Version number
└── V = versioned, R = repeatable
db/migration/
├── V1__create_orders_table.sql
├── V2__add_status_to_orders.sql
├── V3__create_order_items_table.sql
├── V4__add_index_on_order_status.sql
├── V5__insert_default_order_statuses.sql
├── R__create_order_summary_view.sql # Repeatable — re-runs when content changes
└── R__grant_read_permissions.sql
| Strategy |
|---|
| Format |
|---|
| Pros |
|---|
| Cons |
|---|
| Use When |
|---|
| Sequential integers | V1, V2, V3 | Simple, readable | Merge conflicts on version number | Small team, single branch |
| Timestamp | V20260312143000 | No conflicts | Harder to read, unordered by intent | Multiple teams, feature branches |
Recommendation: Use sequential integers for small teams. Switch to timestamps when merge conflicts on version numbers become frequent.
Prefix with R__ — Flyway re-executes them whenever their checksum changes. Use for:
R__create_order_summary_view.sqlR__update_order_totals_function.sqlR__grant_read_permissions.sqlRepeatable migrations run after all versioned migrations, in alphabetical order.