migrations
Data agnostic migrations
Last updated 22 days ago by alexandria .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install migrations 
SYNC missed versions from official npm registry.

node-migrations 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

Current Tags

  • 1.0.0                                ...           latest (22 days ago)

12 Versions

  • 1.0.0                                ...           22 days ago
  • 0.1.12                                ...           22 days ago
  • 0.1.11                                ...           2 months ago
  • 0.1.10                                ...           3 months ago
  • 0.1.9                                ...           3 months ago
  • 0.1.8                                ...           3 months ago
  • 0.1.7                                ...           3 years ago
  • 0.1.6                                ...           5 years ago
  • 0.1.5                                ...           6 years ago
  • 0.1.4                                ...           6 years ago
  • 0.1.3                                ...           6 years ago
  • 0.1.2                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 32
Dependencies (2)
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |