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