PostgreSQL Schema
PostgreSQL Schema is a database migration tool. Based on Schema Evolution Manager.
Installation
The tools can be installed through cabal or stack.
Cabal:
$ cabal install postgresql-schema
Stack:
$ git clone git@github.com:mfine/postgresql-schema.git
$ cd postgresql-schema
$ stack install
Adding Migrations
Add a migration file. The tool schema-add
takes as parameters a file
and a directory containing migrations. By default, the directory
migrations
in the current working directory is used. These
parameters can be overridden on the command line:
$ schema-add --file new.sql --name add-users --dir scripts
Applying Migrations
Apply migrations to a database. The tool schema-apply
takes as
parameters a database and a directory containing migrations. By
default, the directory migrations
in the current working directory
is used, and the database specified in DATABASE_URL
environment
variable is used. These parameters can be overridden on the command
line:
$ schema-apply --url postgres://user@localhost/database --dir scripts
Clearing Migrations
Remove public and migrations schema from a database - USE
CAREFULLY. The tool schema-clear
takes as paramaters a
database. By default, the database specified in DATABASE_URL
environment variable is used. This parameter can be overriden on the
command line:
$ schema-clear --url postgres://user@localhost/database