Skip to content

Instantly share code, notes, and snippets.

@snez
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snez/ce1248661aefc15cb8d0 to your computer and use it in GitHub Desktop.
Save snez/ce1248661aefc15cb8d0 to your computer and use it in GitHub Desktop.
MeanJS migrations with mongo-migrate

MeanJS migrations with mongo-migrate

MeanJS uses the connect-mongo module instead of mongodb, so you will have to add mongodb to your project as a dependency.

$ npm install mongodb --save

Install mongo-migrate

$ npm install mongo-migrate --save

Create a new migration

$ node node_modules/mongo-migrate -runmm create migration-name

Edit

$ vi migrations/XXXX-migration-name.js

Run

$ node node_modules/mongo-migrate -runmm -cfg config/migrations/development.json

Undo

$ node node_modules/mongo-migrate -runmm -cfg config/migrations/development.json down

Where config/migrations/development.json can be

{
	"mongoAppDb" : {
		"host" : "localhost",
		"db"   : "exampleDatabase"
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment