Project is based on epgpool and epgsql.
It supports sql
and erl
migrations description.
- Create migrations folder (for example,
./migrations
) - Create migration file with numeric prefix and
.erl
or.sql
extension.
The prefix must be unique monotonically increasing integer (1,2,3...).
No dupplicates allowed!
- In case of
erl
you need to implementdbschema_migration
behaviour. - In case of
sql
you need to write your sql commands directly.
And specify-- up
and-- down
comments to separate "up" migration part from "down"
- Run
dbschema:up(MigrationDir)
in you_app.erl
start function. - To downgrade call
dbscheam:down(MigrationDir, PrefixNum)
./migrations/1-init.sql
-- Up
create table test(
id serial primary key,
name text
);
-- Down
drop table test;