惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
V2EX
IT之家
IT之家
Jina AI
Jina AI
D
DataBreaches.Net
V
Visual Studio Blog
腾讯CDC
雷峰网
雷峰网
博客园 - 【当耐特】
Y
Y Combinator Blog
阮一峰的网络日志
阮一峰的网络日志
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
MongoDB | Blog
MongoDB | Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
MyScale Blog
MyScale Blog
爱范儿
爱范儿
博客园 - Franky
有赞技术团队
有赞技术团队
Engineering at Meta
Engineering at Meta

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I Built a MongoDB Migration Tool After One Bad Deploy
Santosh Gupta · 2026-06-06 · via DEV Community
Cover image for I Built a MongoDB Migration Tool After One Bad Deploy

Santosh Gupta

A few months ago I shipped a bad MongoDB migration.

Classic mistake.

I had run 3 migrations.

The third one had a bug.

I only wanted to rollback that migration.

Turns out with migrate-mongo, rollback is mostly:

undo the last applied migration

Which sounds fine until you have:

  • multiple deployments
  • multiple environments
  • teammates deploying too

“Last applied” stops feeling obvious.

I ended up manually undoing DB changes and fixing migration history myself.

Not fun.

That was the moment I realized our migration setup had started breaking down as the project grew.

The stuff I kept wishing existed

After that incident I wrote down all the things I wanted from a migration tool:

  • run one migration file
  • rollback a specific migration
  • preview migrations before running (dry-run)
  • avoid concurrent deploys stepping on each other (locking)
  • detect edited migrations (checksums)
  • a redo command for local development
  • TypeScript support without setup pain
  • migration history that doesn’t disappear after rollback

None of these felt unusual.

They felt like things you eventually want once your project stops being small.

So I ended up building one.

Meet mongo-migrate-kit

CLI name: mmk

A few examples:

Run pending migrations:

mmk up

Rollback a specific migration:

mmk down migration-name

Preview before touching production:

mmk up --dry-run

Redo during development:

mmk redo

The hard problem: switching tools safely

This was the part I cared about most.

Migration tools are easy to adopt on day 1.

They’re painful to switch after 50+ migrations already exist.

I didn’t want people to:

  • rerun old migrations
  • recreate indexes
  • duplicate seed data
  • accidentally touch production data

So I added:

mmk import

It reads your existing migrate-mongo changelog and adopts the migration history.

Then:

mmk up

only runs new migrations.

No replaying old history.

No scary production moments.

One thing I intentionally don't support

Imported migrate-mongo migrations are forward-only.

You can’t rollback imported migrations using mmk.

I could have tried to force compatibility, but I didn’t trust it enough to be safe.

Different execution models + database tooling = not something I wanted to gamble with.

So the tool fails loudly instead of pretending everything is reversible.

Curious what other teams are doing

If you're running MongoDB migrations in production:

  • What’s your current setup?
  • Have you hit similar pain points?
  • Are you still happy with migrate-mongo?

Would genuinely love feedback.

Project:

mongo-migrate-kit

Docs/demo:
mongo-migrate-kit.vercel.app

npm:
mongo-migrate-kit