TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: How do you handle mongodb migrations?

5 pointsby uptownhrover 7 years ago
So you wrote your app with mongodb and went live. Maybe some small changes to db structure aren&#x27;t that big of a deal but eventually, you need to migrate data.<p>How have you guys been handling migrations in mongo?

4 comments

jwilliamsover 7 years ago
For really deep, structural (and large datasets), then it&#x27;s pretty difficult to avoid downtime.<p>That said, those circumstances are hopefully pretty rare. We generally write scripts that bridge between the two formats. One to copy&#x2F;transform and one to cleanup after. Run the transform, test and verify, then move to cleanup.<p>It&#x27;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.
评论 #15252922 未加载
CerealBoyover 7 years ago
It&#x27;s been a while since I&#x27;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 &#x2F; instance.<p>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.
pryelluwover 7 years ago
When you say migrate, what do you mean exactly?
评论 #15240318 未加载
nik736over 7 years ago
&quot;So you wrote your app with mongodb and went live.&quot;<p>No.
评论 #15237120 未加载