Is it possible to run migrations with flyway in "2 phases" ?
The problem is that I need to make deploy to production server without any outage and SQL migrations are a problem.
I though I can write every (not every SQL patch will be breaking so most of patches) SQL patch 2 times - once without breaking changes (no column drops etc.) and once with breaking change.
So my question is if it is possible with Flyway.
I imagine something like migrations:migrate --type=non-breaking
and migrations:migrate --type=breaking
And my SQL patch would be named like this:
V1_loremIpsum.non-breaking.sql
V1_loremIpsum.breaking.sql
Having two migrations both called V1__...
won't work as there needs to be an unambiguous ordering, so you will need to rename one of them. If the intention is to run all the non-breaking changes, then do something else such as an application update, then run the breaking ones once the application is confirmed to be up and stable, use the target
option:
V1__loremipsum-nonbreaking-do-these-first.sql
V1_0_1__loremipsum-breaking.sql
/* Only migrates the non-breaking changes */
migrations:migrate --target=1
/* Migrates all - safe to call whether the above has been called or not */
migrations:migrate [--target=latest]