-
Notifications
You must be signed in to change notification settings - Fork 65
Description
Description
Something that is perhaps a bug, but definitely isn't documented, is that Mongock does not throw an exception if two of more change units/logs share the same order
string value. I would have expected it to throw an exception similar to Flyway, given the similar use of version/order numbers.
Looking at the code in ChangeLogComparator.java
, it looks like if the order string is equal, it uses the change unit/log class's canonical name.
I can't think of a use case for allowing duplicate order strings, but recognise it would be a breaking change to start throwing an exception in such cases. It's something to at least think about for a new version.
An alternative short-term approach could also be to log a (warning) message when change logs/units share duplicate order strings in order to warn a developer.
If this is an intended feature, it should be properly documented
In addition, an empty string for the order
value appears to be allowed. This seems contradictory to the documentation, which states it is a mandatory parameter. The change unit ID is also a mandatory parameter, and has checks to ensure it is not null or empty in ChangeLogItem.java
. However this is not done for the order
parameter.
PRIORITY
Normal
Version and environment
Mongock
- Mongock version: 5.4.0
- Modules involved: mongock-springboot-v3, mongodb-springdata-v4-driver
- How Mongock is used: annotation approach (via @EnableMongock and application.yml)
Environment
- Framework and libraries versions. Especially those that affect directly to Mongock(Spring, Spring data, MongoDB driver, etc.): Spring Boot 3.2.3, spring-boot-starter-data-mongodb 3.2.3 (Spring Data MongoDB 4.2.3, MongoDB driver 4.11.1), spring-boot-starter-jdbc 3.2.3 (Spring JDBC 6.1.4)
- Infrastructure: Kubernetes, Docker, SO, etc.: N/A
Steps to Reproduce
Duplicate order values:
- Create two migrations with duplicate
order
string value - When the application starts up and migrations are run, both migrations are run, with order dependent on class name
Empty order values:
- Create a migration with an empty string order
""
- Start the application
Behaviour
Duplicate order values:
Expected behavior: An exception is throw (if this was not an intended feature)
Actual behavior: Mongock allows the duplicate order
values
Empty order values:
Expected behavior: An exception is throw (if this was not an intended feature)
Actual behavior: Mongock allows the empty string order value
How often the bug happens: Always