Registry / database / migoose

migoose

JSON →
library0.2.4jsnpmunverified

Migoose is a migration toolkit for Mongoose, current stable version 0.2.4. It solves the problem of bundling migration files with tools like @vercel/ncc by generating migration code that is imported directly into the codebase, rather than globbing at runtime. Key differentiators: supports TypeScript, no 'down' migrations, uses Mongoose's connection. Release cadence is irregular; it is a young project with limited adoption.

npm install migoose
INSTALL
IMPORT
SIG · MIGOOSE
M
migoose
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.

Migoose
import { Migoose } from 'migoose'
const Migoose = require('migoose')
The package is ESM-only; CommonJS require() will not work.
migoose (CLI)
yarn migoose create
npx migoose create
The CLI command is `migoose`; it runs via yarn or npm scripts. Use `yarn migoose` or `npx migoose` - both work.
Configuration
.migooserc file
migoose.config.js
Configuration is stored in a JSON file named .migooserc, not a JS/TS file.

Shows how to create a migration via CLI and then programmatically run migrations using the Migoose.migrate() function with a mongoose instance.

// 1. Create a migration (CLI): // yarn migoose create // Then edit the generated file in migrations/ // 2. Run migrations in code: import mongoose from 'mongoose'; import { Migoose } from 'migoose'; await mongoose.connect(process.env.MONGO_URI ?? ''); // Import all migrations (assuming they are in a single index.js/ts) await import('./migrations'); await Migoose.migrate(mongoose); console.log('Migrations applied successfully.'); await mongoose.disconnect();
Debug
Known issues
gotchaMigoose does not support 'down' migrations. To revert, you must create a new migration that undoes the changes.
fix
Write a new migration to revert the previous changes; no automatic rollback.
affects: >=0.0.0
gotchaMigrations must be imported (e.g., via await import('./migrations') before calling Migoose.migrate(). If not imported, no migrations will run.
fix
Ensure your migration files are imported into your application's entry point before calling Migoose.migrate().
affects: >=0.0.0
gotchaThe package is ESM-only; using CommonJS require() will fail. Ensure your project is configured for ES modules.
fix
Set "type": "module" in package.json and use import/export syntax.
affects: >=0.0.0
gotchaThe package must be a regular dependency, not devDependency, because migrations run in production.
fix
Install with `npm install migoose` (not --save-dev).
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'migoose'
Migoose is not installed or is a devDependency, or using CommonJS with ESM-only package.
fix
Run `npm install migoose` (not --save-dev) and if using CommonJS, switch to ES modules or use dynamic import.
Migoose.migrate is not a function
The Migoose import might be default import instead of named import, or the module was not imported correctly.
fix
Use import { Migoose } from 'migoose' not import Migoose from 'migoose'.
Upgrade
Version history
0.2.4latest on npm
Audit
Dependencies
mongooserequiredMigoose uses mongoose's connection to run migrations; requires a mongoose instance.
Agent activity
8 hits · last 30 days
node
8
Resources
migoose — npm install migoose · libregistry