/pgsql_migration

PostgreSQL migrations for Erlang

Primary LanguageErlangMIT LicenseMIT

PostgreSQL migrations for Erlang


Simple utility to add migrations for Erlang projects. It doesn't have any database abstraction, you'll still operate with plain SQL and it only supports PostgreSQL (using pgsql or epgsql library). Inspired by erlang-sql-migrations by spawngrid.


Use

In order to use the tool one writes 'migration' files. Most important thing here is to name in the order of their versioning, like this: [timestamp]_name.sql.

-- priv/migrations/1423733547_users.sql
-- :up
CREATE TABLE users();

-- :down
DROP TABLE users;
pgsql_migration:migrate(Conn, "priv/migrations").

You can rename pgsql driver, if you use epgsql 3.0 or newer:

pgsql_migration:use_driver(epgsql).

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request