Reputation: 237
Problem: We have 2 migration files that created the tables using the functions in postgres DB. These tables were created a year ago and after that we have many new migrations. Based on our new standards, we are prohibiting a word that is in the table name.
Example: We are not allowing going forward tables to be named '_audit'. The tables created were are named 'abc_audit' and 'def_audit'.
Prohibiting '_audit' is embedded in the latest function that creates the tables. We can't just alter the table name since docker spins up the entire new db and runs all the migration files and considers only the latest function which prevents '_audit' table name and it fails the original migration.
How do we resolve this? We don't want to re-baseline and lose the history.
Upvotes: 1
Views: 3361
Reputation: 448
It sounds like you need to bring this naming-compliance function into version control.
V1__abc_audit.sql
and V2__def_audit.sql
, followed by V3__something_else.sql
, name your new migration V2_1__naming_function.sql
Now this function will only exist part way through the deployment, after the non-compliant tables are deployed.
For existing Flyway deployments, I suggest using the of the 'out of order' config option. You could do the following:
flyway.outOfOrder
to trueThe 'out of order' option means Flyway will run the new migration in the correct order, despite it being a lower version than the currently deployed version.
Upvotes: 1