Hacker News new | comments | show | ask | jobs | submit login
Ask HN: How do you handle mongodb migrations?
5 points by uptownhr 11 months ago | hide | past | web | favorite | 7 comments
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?

For 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.

How did you go about setting this up? Your own framework or any solutions out there?

It'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.

When you say migrate, what do you mean exactly?

Like a migrate in rdb, with mysql postgres. Something that keeps track and makes DB schema changes.

"So you wrote your app with mongodb and went live."


I 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.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact