Simple, no-frills migration utility.
npm install -g immigration
immigration [command] [options]Options:-d, --directory [dir] The path to migration scripts-b, --begin [name] First script to begin on-c, --count [num] The number of migrations to execute (default: all)-e, --extension [ext] Supported file extensions (default: ".js")-a, --all Explicitly execute all migrations (execute without count or begin)-n, --new Execute the new migrations (used for "up" migrations) *-s, --since Rollback migrations for duration (E.g. "30m") (used for "down" migrations) *Commands:up [name] Run up migration scriptsdown [name] Run down migration scriptscreate [title] Create a new migration filelist List available migrationsexecuted List the run migrations *log [name] Mark a migration as run (without explicitly executing up) *unlog [name] Remove a migration marked as run (without explicitly executing down) *tidy Unlog unknown migration names ** Requires adapter (E.g. "--use [ immigration/fs ]")
Migrations can export two functions:
down. These functions can accept a callback or return a promise for asynchronous actions, such as altering a database.
Adapters can be used with
immigration for persistence of migration state. The built-in adapter is
fs, but others can be created. The only requirement is that they export function called
init which, when called, returns an object with
immigration up -aimmigration down -c1
Loosely based on Rails and node-migrate, but I tried to keep the implementation simpler and more configurable.