3 ms·
Ask HN: How do you handle mongodb migrations?
So you wrote your app with mongodb and went live. Maybe some small changes to db structure aren't that big of a deal but eventually, you need to migrate data.
How have you guys been handling migrations in mongo?
- nik736 9y ago"So you wrote your app with mongodb and went live." No.
- scalesolved 9y agoI don't think is the sort of posting we want on hackernews, either provide some context or advice for the OP as this is not helpful and doesn't contribute anything.
- pryelluw 9y agoWhen you say migrate, what do you mean exactly?
- uptownhr 9y agoLike a migrate in rdb, with mysql postgres. Something that keeps track and makes DB schema changes.
- jwilliams 9y agoFor really deep, structural (and large datasets), then it's pretty difficult to avoid downtime. That said, those circumstances are hopefully pretty rare. We generally write scripts that bridge between the two formats. One to copy/transform and one to cleanup after. Run the transform, test and verify, then move to cleanup. It's a huge pain, but if you keep on top of if --especially the cleanup-- then it gets easier. It tends to get really hard once you get a lot of cruft. You end up with the code vs data dichotomy. So keeping on top of that really helps longer term.
- uptownhr 9y agoHow did you go about setting this up? Your own framework or any solutions out there?
- CerealBoy 9y agoIt's been a while since I've played with mongo, but you could run an out-of-band task to run through all existing data, transform, then push into a new DB / instance. Your existing server would continue, you have a new endpoint to test with updated application code, deployment can then be a standard blue-green approach.