Search code examples
postgresqlflywayredgate

Make flyway log schema history for repeatable migrations


I'm just trying to set flyway up on an existing DB. I want to set all my existing functions and views as repeatable migrations, but I don't want flyway to run them the first time I run migrate, I just want their existing checksum to be added to the history table as though they have been run by flyway in the past.

I thought I would be able to use repair in some way but repair doesn't seem to be working the way I expected. I have tried manually inserting a record into the flyway_schema_history table with a NULL checksum and then running repair. This did nothing repair didn't set the checksum at all.

I also tried creating the SQL file with a dummy statement like SELECT 1; in it, I then ran migrate which added a record to the schema history table, I then updated the SQL file with the function DDL and ran repair. The schema history table was not updated. I then ran migrate and it re-ran the updated repeatable migration and successfully created the function in the DB.

I'm running repair using the exact same options I'm using for migrate, but just changing the command from migrate to repair. Both of these, I'm running from the command line.

Is repair the right way to go? Am I doing something wrong?


Solution

  • It turns out that the answer was -skipExecutingMigrations="true" which logs the migration in the schema history table but does not run it.