Registry / database / mongoose-migrate

mongoose-migrate

JSON →
library0.2.4jsnpmunverified

A migration framework for Node.js that stores migration state in MongoDB instead of a local file, forked from visionmedia/node-migrate. Version 0.2.4 is the latest release (last updated 2013). It requires a config file with MongoDB connection details and uses an environment variable to point to it. Designed for environments like Heroku where the filesystem is ephemeral. Release cadence is low; no recent updates. Differentiator: persists migration records in a MongoDB collection, avoiding the need for a local .migrate file.

npm install mongoose-migrate
INSTALL
IMPORT
SIG · MONGOOSE-MIGRATE
M
mongoose-migrate
databasejavascriptv0.2.4
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.

migrate
const migrate = require('mongoose-migrate');
No ESM support; CommonJS only.
up/down functions
exports.up = function(next) { next(); };
module.exports.up = (next) => next()
Must use function keyword for backward compatibility? Not critical.
config file export
module.exports = { development: { db: 'mongodb://localhost/db', schema: {}, modelName: 'Migration' } };
export default { ... }
ESM export not supported.

Shows setting up a config file with MongoDB connection and creating a simple migration.

// config/migrations.js module.exports = { development: { schema: { 'migration': {} }, modelName: 'Migration', db: process.env.MONGOHQ_URL || 'mongodb://localhost/app_development' } }; // migrations/001-add-users.js exports.up = function(next) { console.log('Migration up'); next(); }; exports.down = function(next) { console.log('Migration down'); next(); }; // Run: NODE_MONGOOSE_MIGRATIONS_CONFIG=./config/migrations.js mongoose-migrate up
Debug
Known issues
breakingRequires NODE_MONGOOSE_MIGRATIONS_CONFIG environment variable. Not setting it causes immediate failure.
fix
Set environment variable before running command.
affects: >=0.0.0
deprecatedPackage last updated 10+ years ago. No support for modern Node.js versions >=12.
fix
Consider alternatives like migrate-mongoose or node-pg-migrate.
affects: >=0.0.0
gotchaMigration files must be in ./migrations/ directory. Custom paths not supported.
fix
Place all migration files in a folder named 'migrations' at root.
affects: >=0.0.0
gotchaThe config file must export an object with environment keys. No programmatic API for config.
fix
Create config file as shown in documentation.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'mongoose-migrate'
Global install not in PATH or package not in node_modules
fix
Install globally: npm install -g mongoose-migrate
Error: env NODE_MONGOOSE_MIGRATIONS_CONFIG not set
Environment variable missing
fix
Set NODE_MONGOOSE_MIGRATIONS_CONFIG=./path/to/config.js before running
Error: failed to connect to server [localhost:27017]
MongoDB not running or connection string wrong
fix
Start MongoDB or update db in config
Upgrade
Version history
0.2.4latest on npm
Audit
Dependencies
commanderrequiredCLI argument parsing
mongooserequiredMongoDB ODM for storing migration state
Agent activity
12 hits · last 30 days
node
10
Amazon
1
Resources
mongoose-migrate — npm install mongoose-migrate · libregistry