0.2.0 • Published 8 years ago

migrashun v0.2.0

Weekly downloads
1
License
ISC
Repository
github
Last release
8 years ago

migrashun

Another abstract migration framework, that lets YOU do all the work!

Installation

$ npm install migrashun

How does it work?

The constructor takes 4 arguments:

var Migrashun = require('migrashun');

var m = new Migrasun(
    filesDir,
    getLastMigration,
    setLastMigration,
    iter
);
  • filesDir: (String) Path to directory where migrations will be stored. This should exist on the filesystem already.
  • getLastMigration: (Function) A function that will fetch the filename of the latest executed migration. This is given a callback that must be called with the filename. Example: function getLastMigration(cb) { db.fetchLast(function (err, doc) { if (err) return cb(err); cb(null, doc.filename); } }
  • setLastMigration: (Function) A function that will save the latest executed migration filename. Again, this is given a callback that must be called after processing. Example: function getLastMigration(filename, cb) { db.saveLast(filename, function (err) { if (err) return cb(err); cb(); } }
  • iter: (Function) OPTIONAL - A function that will receive the filename of the current migration being processed, and the direction (up/down). You can use this to log or do custom printing. Example: function iter(fname, direction) { console.log('Running ', direction, ':', fname); }

API

up(count, cb)

Migrate up.

down(count, cb)

Migrate down

create(title, cb)

Create new migration