Registry / database / mongo-migration

mongo-migration

JSON →
library0.0.3jsnpmunverified

mongo-migration (v0.0.3) is a lightweight MongoDB migration tool for Node.js, designed for simple schema and data migrations. It uses MongoDB driver v3 and focuses on file-based migration management with support for adding migration files and tracking executed migrations in a dedicated collection. Notable features include migration cleanup to synchronize the database state with existing migration files. This package is minimal and unopinionated, suitable for small projects, but lacks advanced features like rollback, CLI, or TypeScript types. Development appears to be early-stage with no recent releases.

npm install mongo-migration
INSTALL
IMPORT
SIG · MONGO-MIGRATION
M
mongo-migration
databasejavascriptv0.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Migration
import { Migration } from 'mongo-migration'
const Migration = require('mongo-migration');
ESM import is recommended. CommonJS require may still work but is not documented.
Migration
const { Migration } = require('mongo-migration')
const mongoMigration = require('mongo-migration'); const Migration = mongoMigration.Migration;
Destructure the named export in CommonJS.
default export
import mongoMigration from 'mongo-migration'
const mongoMigration = require('mongo-migration').default
No default export exists; only named export Migration.

Shows how to create a Migration instance, add migration files, and run migrations using async/await. Requires MongoDB connection URL and database name.

import { Migration } from 'mongo-migration'; import path from 'path'; const config = { url: process.env.MONGO_URL ?? 'mongodb://localhost:27017', database: 'myapp', migrationCollection: 'migrations' }; const migration = new Migration(config); migration.addFile(path.join(__dirname, './migrations/001-initial.js')); migration.addFile(path.join(__dirname, './migrations/002-add-indexes.js')); async function run() { const result = await migration.migrate(); console.log('Migrations executed:', result); } run().catch(console.error);
Debug
Known issues
deprecatedGreenkeeper badge present in README indicates outdated dependency monitoring integration.
fix
Consider switching to Renovate or Dependabot for automated dependency updates.
affects: >=0.0.0
gotchaMissing migration rollback or down functionality. Migrations cannot be reverted automatically.
fix
Manually write reverse migration scripts and execute them separately if needed.
affects: >=0.0.0
gotchaNo TypeScript type definitions provided. Using in TypeScript projects may require custom type declarations.
fix
Create a .d.ts file or use // @ts-ignore.
affects: >=0.0.0
breakingUses MongoDB driver v3 which may be incompatible with MongoDB 5+ or newer driver versions.
fix
Ensure mongodb package version ^3.x is installed. For MongoDB 5+, consider alternative migration tools.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'mongo-migration'
Package not installed or not in node_modules.
fix
Run: npm install mongo-migration
Migration is not a constructor
Incorrect import: using default import instead of named import.
fix
Use: import { Migration } from 'mongo-migration'
MongoError: Authentication failed
Missing or incorrect credentials in MongoDB URL.
fix
Include username and password in the URL, e.g., mongodb://user:pass@localhost:27017
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies
mongodbrequiredpeer dependency for MongoDB driver v3
Agent activity
9 hits · last 30 days
node
8
Resources
mongo-migration — npm install mongo-migration · libregistry