Note: I'm relatively new to Mongo coming from a MySQL background, so please correct me if I'm mistaken anywhere.
The Mongo FAQ on ACID states
MongoDB does not support multi-document transactions
Which leads me to the conclusion that while a migration is running other documents may be created or existing document may be updated. This can be a problem for long running migrations.
So in extending this package for my own application I'm writing a method, for lack of a better word, called "migrationate". It basically takes search parameters and an updater function.
- The search parameters locate non-migrated documents
- The updater function should accept a document from the search, and migrates it in the collection (Note: It must make changes that are detectable from the search parameters)
The search is re-run and documents are sent to the updater function until no documents are found.
There are other details and complexities I'm working through but the above is the gist of it. I think it'll lead to good performance / not lock up mongo, and help ensure every document is migrated.
Questions
- Am I thinking correctly / in a mongo way?
- Does this sound like something helpful to other people?
- Presuming it's helpful, would it be better for me to integrate into this package and make a pull request, or make a separate package?
Note: I'm relatively new to Mongo coming from a MySQL background, so please correct me if I'm mistaken anywhere.
The Mongo FAQ on ACID states
Which leads me to the conclusion that while a migration is running other documents may be created or existing document may be updated. This can be a problem for long running migrations.
So in extending this package for my own application I'm writing a method, for lack of a better word, called "migrationate". It basically takes search parameters and an updater function.
The search is re-run and documents are sent to the updater function until no documents are found.
There are other details and complexities I'm working through but the above is the gist of it. I think it'll lead to good performance / not lock up mongo, and help ensure every document is migrated.
Questions