east postgres
postgresql adapter for east (node.js database migration tool) which uses node-postgres
All executed migrations names will be stored at _migrations
table in the
current database. Object with following properties will be passed to migrate
and rollback
functions:
db
- instance of node-postgres
Installation
npm install east east-postgres -g
alternatively you could install it locally
Usage
go to project dir and run
east init
create .eastrc
file at current directory
"adapter": "east-postgres" "url": "postgres://user:password@127.0.0.1:5432/database"
where url
is url for connect to postgresql db: "postgres://someuser:somepassword@somehost:381/sometable"
now we can create some migrations
east create appleseast create bananas
created files will looks like this one
exports { var db = clientdb; ;}; exports { var db = clientdb; ;};
edit created files and insert
to 1_apples
exports { var db = clientdb; var sqlStr = 'insert into things values($1, $2, $3)'; db;}; exports { var db = clientdb; db;};
to 2_bananas
exports { var db = clientdb; db;}; exports { var db = clientdb; db;};
now we can execute our migrations
east migrate
output
target migrations: 1_apples 2_bananasmigrate `1_apples`migration donemigrate `2_bananas`migration done
and roll them back
east rollback
output
target migrations: 2_bananas 1_applesrollback `2_bananas`migration successfully rolled backrollback `1_apples`migration successfully rolled back
you can specify one or several particular migrations for migrate/rollback e.g.
east migrate 1_apples
or
east migrate 1_apples 2_bananas
Run east -h
to see all commands, east <command> -h
to see detail command help,
see also east page for command examples.
Running test
run east tests with this adapter