A command-line tool for running and managing MongoDB migrations. Version 1.13.0 supports both custom abstraction and native MongoDB operations with transaction handling. It uses YAML config for db connection, migration directory, and changelog collection. Ships TypeScript types. Competing with migrate-mongo, it offers native transaction support via INativeMigration. Release cadence is irregular; recent versions focus on stability and fixes. Works in Node.js (ESM).
npm install db-mongo-migrationNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to initialize, create, and run a migration with a sample migration file using the IMigration interface.
Use import syntax or upgrade to ESM project.
Remove useDefaultTransaction from config entirely.
Use `export default Migration;` at end of migration file.
Ensure .env file exists in working directory or set variables explicitly.
Run `npm install db-mongo-migration` and ensure your project is set to ESM (type: module in package.json or use .mjs extension).
Check the URL and databaseName fields; ensure environment variables are set correctly. Use URL format: mongodb://user:pass@host:port/db
Use the provided DB object methods (e.g., db.collection()). If you need native Db, use INativeMigration interface instead.