Skip to content

Why mongo-migrate-kit?

Most MongoDB migration tools run every pending migration, then only undo the last one. mongo-migrate-kit gives you precise control over what runs and what rolls back — and won't leave your database half-migrated when something fails.

Where to start

New to migrations? Read Core Concepts, then follow the Tutorial.
Done this before? Jump to Getting Started, the CLI Cheatsheet, or the Programmatic API.

Reasons to choose it

  • Run a single migrationmmk up <file>, not just "all pending".
  • Roll back anything — a batch (--batch 3), the last N (--steps 2), one file, or redo.
  • Preview before you runmmk dry-run up prints the exact plan without touching the database.
  • No race conditions — an atomic MongoDB lock stops two deploys running migrations at once.
  • Tamper detection — SHA-256 checksums catch a migration edited after it was applied.
  • Audit trail kept — a rollback updates the record, it never deletes it.
  • Lifecycle hooksbeforeAll, afterAll, beforeEach, afterEach, onError.
  • Opt-in transactions — wrap a migration so it fully commits or fully aborts.
  • TypeScript, ESM & CommonJS — all run with no ts-node plumbing.
  • Zero config files required — drive everything from env vars if you prefer.

vs. migrate-mongo

Capabilitymigrate-mongomongo-migrate-kit
Run a single migration file
Roll back a specific batch (not just the last)
Dry-run preview
redo (down + up)
Checksum / tamper detection
Lifecycle hooks
First-class TypeScript (built-in)
History kept on rollback (never deleted)

Already on migrate-mongo?

Switch in one command — mmk import adopts your existing changelog as-is, with no re-running and no data loss. See Migrating from migrate-mongo.

Next

Released under the MIT License.