-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatic reruns? #21
Comments
You're thinking along the right lines there with Mongo's lack of transactions. However, your concern is tied to how/when your run your migrations. In our case, we deploy our code first, then run the migrations. The code should be robust enough to handle the old/new schemas. Likewise, the migrations should be able to handle data that is already migrated. This way, the migrations will convert any old data they 'see', whilst data written during the migration is running will already be using the latest schema. It seems unnecessary to introduce extra complexity by way of an 'updater' function. |
Thanks for the explanation, I can understand your approach and see benefits to it even though I go a different direction. While developing quickly in a beta application I prefer to ignore application code 'backwards schema compatibility'; I want to minimized the code I write that's only needed for as long as a single migration takes to run. And give myself more freedom to change the schema. This procedure is closer to what I do to save developer time:
Steps 2 & 3 are mostly in order, though I don't trust them to always be perfect. For example a client's code may not update right away (perhaps I need to trust meteor more). And though steps 1 & 4 mitigate my concern of users updating documents during migration, I often skip them because of a combination:
In effect I often make the choice of prioritizing the combination of developer time & up-time over a few quirks being seen. I mitigate these issues with re-usable solutions like 'migrationate' when possible. I don't think one solution is strictly superior to the other, but each have their use with different constraints. That said, presuming what I'm doing is helpful to others, I'm now thinking 'migrationate' belongs in it's own package to keep this core migration package simple. |
Fair points. Agreed it probably belongs in its own package. Good work. |
Cool thanks. Feel free to leave close this issue when you see fit. The main benefit now would be to see if there's community demand for this which would motivate me to package it up. |
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
The text was updated successfully, but these errors were encountered: