Flyway states in its documentation some of the usages for repeatable migrations:
Usages: (Re-)creating views/procedures/functions/packages/...
I have some triggers/functions that I want to create in a repeatable migration, these are later referenced in version migrations, where they are applied to tables.
Flyway runs repeatable migrations last, which means the triggers don't exist when they are referenced.
Is it possible to run certain repeatable migrations before versioned ones?
Is this use case not supported because it would be bad practice to automatically update triggers that are applied to tables?
I don't think it's possible to call repeated migration scripts first.But you can use callback scripts for your purpose. Read about it here.
So you can have a script called beforeMigrate.sql
within a migration script directory and use it to initialize what you want.
Though I don't understand, why not to recreate triggers after the versioned migration is done? If you have temporary(short-living) objects like some triggers, that seems to me right, to bind them to the permanent objects in the same script they are declared - I mean in the repeated migration script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With