mongock / mongock

Lightweight Java based migration tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clarify ordering mechanism in docs

PieterDr opened this issue · comments

The order in which ChangeUnits are executed is based on alphabetical order of the "order" property of the ChangeUnit annotation. The ChangeUnit example in the documentation however states: order = "1". This gives the impression that ordering is based on the numerical value.

In our application, we've written multiple ChangeUnits and we ran into the issue that order = "10" was executed before order = "2". In hindsight, it is logical that the ordering is done alphabetically, since it is a String property. This should be mentioned explicitly in the docs imo though. The example could maybe also be modified to remove this source of confusion. Or, even better would be to change the order property to int in a next release.

Thanks for pointing that out! We'll clarify that in the documentation!

I just realized the same thing while preparing multiple ChangeSet methods. What's the best way to define order to get this sorted without running into any issues like 2 vs 10

We just went with leftpadding with 0's: @ChangeUnit(id = "migration-00012", order = "00012"). Now we're covered until migration 99999 which I hope we'll never reach :D

We just went with leftpadding with 0's: @ChangeUnit(id = "migration-00012", order = "00012"). Now we're covered until migration 99999 which I hope we'll never reach :D

Thank you so much... will probably use the same strategy/

We just went with leftpadding with 0's: @ChangeUnit(id = "migration-00012", order = "00012"). Now we're covered until migration 99999 which I hope we'll never reach :D

Thanks, we will add this to the documentation, as up to this point, introduce a break change here is not a good option.