node package manager


Mongoose Migrations

What's this?

A library that runs migrations on mongoose based systems.

How it works?

Just import the library

const migrations = require('mongoose-migrations');

and run it mongoose, 'directory');

Where mongoose is some instance of the mongoose lib Where directory is the folder with the migrations

What are migrations?

Are like those from rails, to upgrade data or database structures;

What are the file format for migrations?

Create a folder with the migrations files. Each migration should be named as number and should be a .js file. Each migration should export a .run() method and return a promise.

Eg: 1.js, 2.js, 10.js

After some migration was ran, only migrations with a number bigger than that will be ran.