Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migration versions across multiple directories

If I want to organize my migrations in multiple directories (let's say I'm using SQL migrations, and under the "sql" directory I have a "main" directory and then a "special" directory).

So under sql/main I have "V1.1__some_change" etc.

Then I want to put other migrations under sql/special as well. But the migration version numbers have to be distinct across all the directories, e.g., I couldn't put "V1.1__some_other_change" in sql/special as it would cause a conflict.

But it's not that easy to manage a linear version number across many different directories. Is there a good approach to solve this issue?

Hope this question is clear.

like image 995
user2009267 Avatar asked May 22 '26 03:05

user2009267


1 Answers

Well it all depends on why special is "special" and how it is related to "main".

If they have the same lifecycle you could use a different numbering scheme (whole number in main, point releases in special) or track the assigned migration number in a shared resource (whiteboard, wiki page, ...) to make it easy to know which the next available one is.

If they have separate lifecycles, you could have separate Flyway instances tracking them (each with a different flyway.table).

like image 90
Axel Fontaine Avatar answered May 26 '26 21:05

Axel Fontaine