Flyway - Change order of execution of migration scripts
tjnorman57
Posts: 2 New member
in PostgreSQL
I have a developer who created a versioned script and a repeatable script. The problem is the order of the scripts in which he did it. Currently, the versioned script is right after the baseline, and the repeatable script is after the versioned. The problem is that data in the repeatable script must be deployed before the versioned script because of foreign key relationships. Is it possible to move the order of execution in migration scripts?
Answers
Josh Head (Support)
Dec 11, 2024, 21:24 GMT
So, there are a couple of things you can try. One is to set up a script configuration to run the scripts on a per-script basis. The documentation for that is here: https://documentation.red-gate.com/fd/script-configuration-248284640.html, more specifically using the "should execute" option: https://documentation.red-gate.com/fd/should-execute-248284771.html
There's also an option to Skip Executing Migrations which can be used in conjunction with cherry pick.
You could also convert the repeatable migration to a versioned migration by renaming the repeatable script to follow the versioned migration naming convention (e.g.,
V2__Your_Repeatable_Script.sql
), you can control its execution order by assigning an appropriate version number that ensures it runs before the dependent versioned script.Let me know if you have any questions about the above options.
Thanks,
Josh Head
Product Support Engineer