feat: auto migration resume with FETCH_ALL #31
Merged
Conversation
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
a2c4286 to
ac7e231
Compare
Contributor
Author
|
@hugop95 We did this PR with Elisa using Claude (our new best friend), but I think I would have exactly implemented this like that! Does the solution look good to you? @elisap360 I added type safety to prevent |
hugop95
reviewed
Mar 18, 2026
Contributor
Author
|
@hugop95 Thanks a lot for the rework, I was honestly a bit hurried when I pushed and didn't take the necessary time to clean what Claude did (first time and lesson for later, won't happen again and sorry you had to waste time fixing it). |
hugop95
approved these changes
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #30
Problem to solve
When a migration is stopped then re-run, MBDM will fetch using the same query:
This is not a problem if we know how to differentiate fields before and after (for example, a field is added)
However, it's a problem if we don't know how to differentiate a doc that has been migrated (for example, an updated field)
In this case, the script is not resumable, it will start from the beginning.
In this case document already processed won't backed up again, but updated again. This is not really a case intended and covered.
Warning
It can also be dangerous ; if the migration is not idempotent, it will modify the document again 💥 (for instance, an increment⚠️ )
Solution
We can solve this by preventing an empty query.

This PR does this with Type safety and hint like this:
This PR adds the new special query
FETCH_ALLthat wil do the same as{}empty query.What it does
Instead of fetching all docs:
To support big migrations, we fetch only one doc. So this features relies on the fact document
_idis reliable and ascendant. (it won't work if we insert a doc with a lower _id in between of the migration).