Found more than one migration with version XXXX
rsksmiles
Posts: 3 New member
I have an issue whereby 2 developers in a team are working in the same GIT branch and making database modifications.
They both create a script say V2_1_25__bla_bla1 and V2_1_25__bla_bla2
These changes are committed to GIT.
When the refresh their code they then see the 2 script files but when they try to run flyway to update the database the execution fails due to the duplicate version numbers: "Found more than one migration with version 2.1.25"
What is the best way to handle this?
Thanks for your help in this
They both create a script say V2_1_25__bla_bla1 and V2_1_25__bla_bla2
These changes are committed to GIT.
When the refresh their code they then see the 2 script files but when they try to run flyway to update the database the execution fails due to the duplicate version numbers: "Found more than one migration with version 2.1.25"
What is the best way to handle this?
Thanks for your help in this
Best Answers
-
AlistairW Posts: 36 Bronze 2The conventional approach is to check before committing - Flyway uses the version numbers to order your migrations and it may be important which V2 is applied first.
An alternative is to embed a timestamp in the version number which makes it very unlikely that you'll get a conflict. You can develop your own process for this or else there is a new verb in preview that can create the empty migration for you - https://documentation.red-gate.com/fd/command-line-add-254155068.html
So you'd want something like this to create the file:
flyway add -add.description=new_feature -add.addTimestamp=true
-
AlistairW Posts: 36 Bronze 2You run into the limitations of a point tool - the situation you describe needs some way of coordinating everyone and that is non-trivial. Flyway aims to solve the problem of being able to change your DB in a controlled manner and recreate it's current state should you need to do so. Coordinating development work is a related problem but will involve other tools and practices to solve (Redgate has some but they aren't free)
On your specific question though, dev1 would need to clean their development DB and re-apply all the migrations which would correct the ordering to include dev2's changes.
Answers
This resolves the issue of the version number but what happens if dev 1 has run their change on his db and dev 2 has a change with an earlier timestamp? flyway won't consider the earlier version when dev 1 receives that script.
Is there a way to force flyway to execute unexecuted scripts? I can see that can lead to issues where a certain script should be run after another and not before.... comes down to communicating clearly between devs which is not always easy in multi timezone teams ... aaagggh!
Does that make sense?
Whilst it would be nice to have an out of the box solution, I can work with the "lets talk" solution within the team.
Product Manager
Redgate Software