Mongo Migra is a simple, dependency-light migration tool for MongoDB databases, version 1.8.0 (stable release cycle ~1 year). It uses the native MongoDB Node.js driver directly, with no ORM or additional abstraction. Key differentiator: supports replica sets and transactions, allowing migration scripts to use sessions. It also offers TypeScript type definitions and a CLI for creating, deleting, applying, rolling back, and tracking migrations. Unlike other tools, it avoids heavy frameworks and keeps the setup minimal.
npm install mongo-migraNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initialize and run all pending migrations using TypeScript with environment variable for URI.
Use ES module imports (import) instead of require().
Omit compile step; run with ts-node or use node with transpiled JS.
Ensure MongoDB is running as a replica set (even a single-node replica set) for transactional migrations.
Use syntax: mongo-migra action=up config=./custom-config.json
Switch to ESM (import mongoMigra from 'mongo-migra') or update Node to support ESM.
Configure MongoDB as a replica set (e.g., single-node replica set) before running transactional migrations.
Run 'npm install mongo-migra' in the project directory, or use global install if running CLI globally.
Upgrade Node.js to >=12.22.0 or use a transpiler like Babel.