npm

Need private packages and team management tools?Check out npm Orgs. »

migrations

0.1.7 • Public • Published

node-migrations

Data agnostic migrations

Installation

npm i migrations

Usage

In order to use this module you need to have a bootstrap file (e.g. migrations.js) where you can initialize db, specify your own meta storage adapter and so on.

var Migrations = require('migrations'),
  MetaFile = require('migrations/lib/meta/file');
 
module.exports = new Migrations({
  dir: __dirname + '/migrations', // directory with migration files
  meta: new MetaFile({path: __dirname + '/migrations.json'}) // meta information storage
});
 
module.exports.run();

You can specify your custom store of meta data, e.g.:

var Migrations = require('migrations'),
  meta = {};
 
// Meta Storage has very basic interface:
var storage = {
  get: function(cb) { cb(null, meta) },
  set: function(value, cb) { meta = value; cb() }
};
 
 
module.exports = new Migrations({
  dir: __dirname + '/migrations',
  meta: storage // custom storage
});
 
module.exports.run();

Using with npm

You can put a special task in package.json file:

{
  "name": "my-project",
  "scripts": {
    "migrate": "node migrations.js"
  }
}

and then you be able to do npm run migrate. Another option is to add shebang to the migrations executable and run it in a manual way.

Cli interface

  Usage: migrations.js [options]

  Options:

    -h, --help  output usage information
    --up      Migrate up
    --down    Migrate down
    --create  Create empty migration file
    --count   Migrate particular number of migration
    --revert  Revert last migration

install

npm i migrations

Downloadsweekly downloads

734

version

0.1.7

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability