npm

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

migrant

0.1.1 • Public • Published

node-migrant

Data agnostic migrations

Installation

npm install migrant

Usage

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

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

var Migrant = require('migrant'),
  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 Migrant({
  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 migrant.js"
  }
}

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

Cli interface

  Usage: migrant.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

Keywords

none

install

npm i migrant

Downloadsweekly downloads

4

version

0.1.1

license

none

last publish

collaborators

  • avatar
Report a vulnerability