Safely update your MongoDB database structure across multiple deployments without running every migration each time.
Roll back a broken migration in production by reverting just that one file, without touching unrelated changes.
Test what a migration will do before it runs, using dry-run mode so nothing in the database changes.
Migrate an existing migrate-mongo project to get better controls without rewriting any migration files.
Install via npm, run mmk init to generate a config file. Connection string and DB name can be passed as env vars instead. No extra build tools needed.
mongo-migrate-kit is a command-line tool for managing MongoDB database migrations in Node.js projects. A migration is a script that changes the structure or content of a database in a controlled, versioned way: for example, adding an index, renaming a field, or moving data between collections. This tool is written in TypeScript and works in TypeScript, ESM, and CommonJS projects without requiring extra build-step tools. The main selling point over older tools like migrate-mongo is a more precise set of controls. You can run a single named migration file rather than being forced to run everything pending. You can roll back by batch number, by a count of recent steps, or by a single file. There is a dry-run mode that prints exactly what would happen without touching the database at all. An atomic lock stored in MongoDB itself prevents two deployment processes from running migrations at the same time. SHA-256 checksums are recorded when a migration is applied, so the tool can detect if the file was edited afterward, which is a common source of hard-to-debug inconsistencies. When you roll back, the history record is updated rather than deleted, so you always have a full audit trail. You can also define lifecycle hooks at four points in a migration run (before all, after all, before each, after each, and on error) and opt individual migrations into transactions so that a migration either fully completes or fully aborts. If you are already using migrate-mongo, a single mmk import command reads your existing changelog and adopts it as-is, so past migrations are recognized as already applied and only new ones will run. No data is lost and no migration files need to be rewritten. Install it from npm, run mmk init to generate a config file, then use mmk create, mmk up, mmk down, and mmk status to manage migrations. A config file is optional if you prefer to pass the database connection string and database name as environment variables. Full documentation is hosted separately. The project is licensed under MIT.
← guptasantosh327 on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.