Registry / database / mongoomig

mongoomig

JSON →
library1.1.7jsnpmunverified

Yet another mongoose migration tool, version 1.1.7. It provides a simple way to manage MongoDB schema migrations using Mongoose with async/await. Key features include zero runtime dependencies (only peer dependency mongoose >=4), TypeScript support via ts-node, configuration through CLI, environment variables, or config file, and support for up/down/list/create commands. Release cadence is low; the package is stable and in maintenance mode. Differentiators: minimalistic, no additional dependencies, and designed for async/await.

npm install mongoomig
INSTALL
IMPORT
SIG · MONGOOMIG
M
mongoomig
databasejavascriptv1.1.7
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 'mongoomig'
const Migration = require('mongoomig').Migration
Package exports Migration class as a named export. ESM usage recommended.
runMigration
import { runMigration } from 'mongoomig'
Assumed as a named export if available; check package exports.
default
import mongoomig from 'mongoomig'
const mongoomig = require('mongoomig')
Default export is the Migration class; use named import for clarity.

Shows how to programmatically run all pending migrations using the Migration class.

import { Migration } from 'mongoomig'; const migration = new Migration({ url: process.env.MONGO_URL ?? 'mongodb://localhost/mydb', path: './migrations', collection: 'migrations' }); async function run() { await migration.connect(); await migration.up(); console.log('Migrations applied successfully'); process.exit(0); } run().catch(err => { console.error(err); process.exit(1); });
Debug
Known issues
deprecatedThe 'create' command creates migrations with CommonJS format by default; for ESM projects, you need to manually adjust.
fix
After creating a migration file, convert its syntax to ESM imports/exports if needed.
affects: >=1.0
gotchaThe 'require' option (--require) is used to load modules before migrations, but it doesn't handle ESM modules natively. Use ts-node/register for TypeScript.
fix
Use '--require ts-node/register' when using TypeScript.
affects: >=1.0
breakingMongoomig uses Mongoose's default connection. If you already have a Mongoose connection in your app, migratory operations may interfere.
fix
Manage connections manually or ensure migrations run before app logic.
affects: >=1.0
gotchaConfig file resolution: if no config provided, mongoomig looks for ./migrations/config.js. Non-existence causes silent default.
fix
Explicitly set config path via --config or environment variable to avoid surprises.
affects: >=1.0
Errors
Common errors & fixes
Error: Cannot find module 'mongoose'
Missing mongoose as a dependency. It is a peer dependency not installed automatically.
fix
Run 'npm install mongoose' in your project.
TypeError: migration.connect is not a function
Using outdated API or incorrect import. The Migration class may have a different method name.
fix
Check the API: use 'migration.connect()' as shown in the documentation.
Upgrade
Version history
1.1.7latest on npm
Audit
Dependencies
mongooserequiredPeer dependency: required for database connection and schema operations
Agent activity
15 hits · last 30 days
node
14
Resources
mongoomig — npm install mongoomig · libregistry