Skip to content

mongo-migrate-kitElegant MongoDB migrations for Node.js

Precise, safe migrations for MongoDB. Run a single file, roll back anything, and preview every change before it touches your database.

mongo-migrate-kit logo

See it run ​

A preview, a real run, then rolling back one migration by name. This is the actual output.

Terminal: mmk dry-run up lists three pending migrations, mmk up applies them, mmk down rolls back one file by name, and mmk status shows the result

Also in VS Code ​

Mongo Migrate Kit for VS Code gives you a migration console, a sidebar and run links in your files. It runs your project's own mmk, so the editor and the terminal always agree.

The Mongo Migrate Kit console in VS Code: every migration on local, staging and prod; a plan of three pending migrations, applying them with mmk's output as it comes, the result, rolling the batch back, then prod (read-only) while a CI deploy holds its lock, and the form that edits an environment
You want toIn a terminalIn VS Code
See what would run, then run itmmk dry-run up, then mmk upPlan, then Apply, with mmk's output as it comes
Run or roll back one filemmk up <file>, mmk down <file>The links above up() and down()
Roll back a batchmmk down --batch <n>Roll back batch n… in the console
Compare local, staging and prodmmk status once per databaseOne table in the console
See who holds the lockmmk lockA line in the console and the sidebar
Notice an edit to a migration that already ranmmk status, after you saveA warning while you type

Install it and see what it does →

Learn it in four steps ​

Start at the top. Each step takes you a bit further, and you can stop whenever you have what you need.

  1. Get it runningabout 10 minutes

    Install it, write your first migration, run it and roll it back.

    Quick start →
  2. Understand itabout 15 minutes

    What a batch is, where the history lives, and how the lock and checksums protect you.

    How it works →
  3. Use it in productionabout 30 minutes

    Config, CI pipelines, running on app start, transactions, and what to do when something fails.

    Deploying →
  4. Bigger setupswhen you need it

    Several repos on one database, moving off migrate-mongo, and long-running data changes.

    Sharing a database →

Already on migrate-mongo? ​

Point mmk at the same database and run mmk import. It copies your history into its own collection and never changes the old one. After that, mmk up only runs what's new.

Terminal: mmk import --dry-run previews three migrate-mongo records, mmk import copies them, and mmk up applies only the one new migration

Read the switching guide →



Released under the MIT License.