migrant
v0.1.1
Published
node-migrant ============
Downloads
1
Readme
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