1.5.0 • Published 9 days ago

migrations v1.5.0

Weekly downloads
457
License
MIT
Repository
github
Last release
9 days ago

node-migrations

npm version Build Status

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
  template: '', // template used by `--create` flag to generate a new migration file
});

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
1.5.0

9 days ago

1.4.1

4 months ago

1.4.0

7 months ago

1.3.0

2 years ago

1.2.1-0

2 years ago

1.2.1-beta.0

2 years ago

1.2.0

2 years ago

1.0.2

3 years ago

1.1.0

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago

0.1.12

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.8

4 years ago

0.1.9

4 years ago

0.1.7

7 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

10 years ago