1

My application uses mongock 4.1.19 and when ever there is a changeSet with runAlways=true, there are duplicate entries getting created in the dbchangelog collection.

the below line does not seem to consider already executed case and may be resulting in duplicate changelog entries

Any pointers on how this can be addressed

https://github.com/cloudyrock/mongock-core/blob/91d15d65a22234f4a2e8d28c759d0641d36750e0/mongock-runner/mongock-runner-core/src/main/java/com/github/cloudyrock/mongock/runner/core/executor/MigrationExecutor.java#L139

Below Logger logged at startup - RE-APPLIED - ChangeEntry{...}

Tar
  • 13
  • 4
  • After analysing the issue, Mongock team decided to keep the current behaviour. The reason being is that the changeLog collection is the history of the changeUnits executions. By doing this update, we would be losing information that we may need. Keep in mind that this collection is not intended to be used by the developer - but are used as part of Mongock's internal process. To view changeUnits, there is a CLI that allows you to view the DB state and history of changes. You can test the CLI following this link: docs.mongock.io/v5/cli/index.html – Mongock team Sep 05 '22 at 14:37

1 Answers1

1

It's not really duplicated. It creates a changelog entry per execution.

However, we understand this is not the more common desired behaviour, we are releasing a bugfix(4.3.8) for version 4 in the next days, probably today.

In version 5, which is under development, we'll keep this by default, plus updating the last_execution field we'll add, and add the option to insert a new entry per execution if desired.

Mongock team
  • 1,188
  • 5
  • 9
  • Did that field ever get added? – SQB Aug 16 '22 at 09:08
  • After analysing the issue, Mongock team decided to keep the current behaviour. The reason being is that the changeLog collection is the history of the changeUnits executions. By doing this update, we would be losing information that we may need. Keep in mind that this collection is not intended to be used by the developer - but are used as part of Mongock's internal process. To view changeUnits, there is a CLI that allows you to view the DB state and history of changes. You can test the CLI following this link: https://docs.mongock.io/v5/cli/index.html – Mongock team Sep 05 '22 at 12:16