Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to squash/merge migrations in flyway

Tags:

oracle

flyway

Let's say I have migrations script from V1_1 to V1_300 - it is quite a huge number and takes very long period of time. But from time to time there is a release - can I, from the point of flyway, somehow merge all those migrations so:

  • All migrations from V1_1 to V1_300 will be in one file (for instance: V2_1)
  • Amount of time taken by these migrations will drop

Checking for overlaps manually is really time-consuming. Thank you in advance for your answers.

like image 259
Mateusz Chrzaszcz Avatar asked Aug 26 '14 12:08

Mateusz Chrzaszcz


1 Answers

We had the same problem on my project and decided to do a roll up of versions already deployed to production. To roll up incremental changes into 1 file, I ran the migration from scratch in a database then dump (export) back the whole database in 1 SQL file. I named the file using the last version of the migration. In your case V1_300__rollup.sql. Then you can continue adding new versions: V2_1, V2_2, etc. and repeat when you want to roll up.

like image 131
Sylvain Guillopé Avatar answered Oct 19 '22 13:10

Sylvain Guillopé