Any way to “compress” Flyway migrations?

前端 未结 3 868
慢半拍i
慢半拍i 2020-12-08 19:18

We are using Flyway to migrate the database schema and we already have more than 100 migration scripts.

Once we \"squashed\" multiple migrations into a single first-

3条回答
  •  佛祖请我去吃肉
    2020-12-08 19:45

    I haven't tried this, but what if you deleted all the migrations, create a new migration that creates the new starting point as version 1, set it as the baseline version -- and then modify your configuration to use a different table (e.g. flyway_schema_history_2)?

    In existing databases, Flyway will see that you have a non-empty schema with no (recognized) flyway table and ignore the baseline migration. In new environments it will run the baseline migration too.

    Am I missing anything?

    (Of course a separate problem is how to generate the "compressed" migration. If you don't need any seed data you can just do a schema-only backup of your database and use that. If your migrations populate data too you will probably have to work that out manually.)

提交回复
热议问题