How do Flyway versioned and repeatable migrations differ?
basicVersioned migrations (V3__add_orders.sql) run exactly once, in version order. Repeatable migrations (R__refresh_views.sql) have no version and re-run whenever their checksum changes, after all versioned ones.
- History is tracked in the
flyway_schema_historytable (version, description, checksum, success flag). - Use repeatables for idempotent objects: views, functions, stored procedures (
CREATE OR REPLACE). - Repeatables run in alphabetical order by description, so dependencies between them need naming discipline.
- Spring Boot runs Flyway on startup when
flyway-coreis on the classpath (Boot 3 with Flyway 10 needs database modules likeflyway-database-postgresql).
- Can you edit an applied versioned migration? No, the checksum changes and validation fails.
- Can a repeatable depend on a table created in a later versioned file? All versioned run first, so yes.