Erlang postgresql migrations util
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
include
src
test
.gitignore
.travis.yml
LICENSE
README.md
rebar.config
rebar.config.script

README.md

Build Status Coveralls GitHub tag Hex.pm

Erlang PostgreSQL migrations utils


Description

Project is based on epgpool and epgsql. It supports sql and erl migrations description.

Usage

  1. Create migrations folder (for example, ./migrations)
  2. 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 implement dbschema_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"
  1. Run dbschema:up(MigrationDir) in you _app.erl start function.
  2. 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;