Search code examples
refactoringflywayrefactoring-databases

How to start flyway script versions over


My flyway scripts are getting a bit extensive, and it takes a while to wipe and recreate a schema. It's getting unwieldy, and I figure others have hit this situation with flyway.

I would like to start the scripts over: create a snapshot of the current database, give it a version one, and start over from there.

But for production databases, I'll never be wiping the schema, and I don't want it to parse through the history each time, and get conflicts on the version numbers. I figure I will need to recreate the schema_version table, but it seems a bit finicky. Has anyone done this, and could you give me instructions on your process?

Thank you.


Solution

  • What you can do is

    • dump your db structure, and give this the current version of your db (this will help you recreate it in dev)
    • drop the schema_version table from prod
    • flyway.init() prod with the version of the dump
    • get rid of all previous migration scripts and keep only the dump