오래된 마이그레이션을 다시 실행하지 않고 Migrate Mongo에서 Mongo Migrate Kit (mmk) 로 이동

작성자

카테고리:

← 피드로
DEV Community · Santosh Gupta · 2026-06-25 개발(SW)

If you’re using migrate-mongo and considering a switch, the biggest concern usually isn’t features.

It’s this:

“Will I have to re-run old migrations or risk production data?”

The short answer is no.

I built mongo-migrate-kit with migration adoption as a first class feature because switching migration tools shouldn’t feel risky.

The Problem

Most teams already have months or years of migration history.

Re-running old migrations is dangerous.

Editing migration records manually is even worse.

What you really want is a way to tell the new tool:

“These migrations already ran. Start tracking them and leave everything else alone.”

That’s exactly what mongo-migrate-kit does.

Import Existing migrate-mongo History

First, install the package:

npm install mongo-migrate-kit mongodb

Enter fullscreen mode Exit fullscreen mode

Preview the import:

npx mmk import --dry-run

Enter fullscreen mode Exit fullscreen mode

This reads your existing migrate-mongo changelog and shows what will be imported.

Nothing is written to the database.

Once you’re happy with the output:

npx mmk import

Enter fullscreen mode Exit fullscreen mode

The migration history is copied into mongo-migrate-kit‘s tracking collection.

Your original migrate-mongo changelog remains untouched.

What Happens Next?

After importing:

npx mmk status

Enter fullscreen mode Exit fullscreen mode

Previously applied migrations appear as applied.

Any migration files that haven’t run yet remain pending.

When you run:

npx mmk up

Enter fullscreen mode Exit fullscreen mode

Only pending migrations execute.

Old migrations are never re-run.

Why I Built This

I originally created mongo-migrate-kit after running into rollback issues during a deployment.

While using migrate-mongo, I found myself wanting more control over migration safety and deployment workflows.

That led to features such as:

  • Rollback specific migrations or batches
  • Dry-run support
  • SHA-256 checksum validation
  • Distributed migration locking
  • Redo support
  • TypeScript support
  • Safe migration adoption from migrate-mongo

Documentation

Getting started takes only a few minutes:

Deep dive on migration guide from migrate mongo:
https://mongo-migrate-kit.vercel.app/guide/migrate-mongo

npm:
https://www.npmjs.com/package/mongo-migrate-kit

GitHub:
https://github.com/guptasantosh327/mongo-migrate-kit

Final Thoughts

Migration tools should make deployments safer, not add anxiety.

If you’re looking for a migrate-mongo alternative or need a MongoDB migration tool for Node.js that can adopt existing migration history safely, give mongo-migrate-kit a try.

원문에서 계속 ↗

코멘트

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다