exodusjs
Simple postgres database migrations
Last updated a year ago by swlkr .
MIT · Repository · Bugs · Original npm · Tarball
$ cnpm install exodusjs 
SYNC missed versions from official npm registry.

exodus.js

Simple postgres database migrations

Install

$ npm i -D exodusjs # short for npm install --save-dev exodusjs

How Do I Use It?

$ export DATABASE_URL=postgres://postgres:@localhost:5432/database
$ exodus create add-events-table # this creates a migrations/ folder in the current directory along with a new migration file!
$ exodus migrate
$ [EXODUS] Running 1 migration
$ [EXODUS] Ran migration 20150811090001-add-events-table
$ [EXODUS] Finished
$ exodus rollback
$ [EXODUS] Rolling back 1 migration
$ [EXODUS] Rolling back migration 20150811090001-add-events-table
$ [EXODUS] Finished

What Does A Migration Look Like?

// 20150811090001-add-events-table
var migration = {
  up: `
    your sql goes here
  `,
  down: `
    your sql goes here
  `
};

module.exports = migration;

A Real Migration

var migration = {
  up: `
    create table events (
      id bigserial primary key,
      data json,
      created_at timestamp without time zone default now()
    );
  `,
  down: `
    drop table events;
  `
};

module.exports = migration;

How Does It Work?

When you run exodus migrate for the first time, a migrations table is created in your database and it tracks which migrations have been run.

What's With The Name?

Migrations... exodus... they're synonyms. You get it.

Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |