database-schemaflywaydbmigraterepair

Flyway - why all my schemas were deleted and how can i revert it


I was running a db repair command on my db, and surpassingly found out later that for each old migration version a new DELETE migration was created. It was only effecting the flyway_schema_history table, the rest of the tables stayed the same, and nothing was deleted/ dropped.

But, now when I am trying to run migrations scripts I get failures when running the flyway, since it tries to run the first migration script again. I do not want to delete this migrations.

Can someone explain to me why did it happen, and much more important, do I have a way to revert it and delete the DELETE rows?


Solution

  • As of Flyway 7, running repair marks any migrations that are Missing as DELETED in the flyway_schema_history table, which is a way of telling Flyway that the migrations have been removed

    If the migrations aren't Missing, what has likely happened is you haven't configured flyway.locations when running repair

    As for fixing it, there are two options that are the most ideal as of today: