postgresql-orm-0.2: An ORM (Object Relational Mapping) and migrations DSL for PostgreSQL.

Safe HaskellNone

Database.PostgreSQL.Migrate

Description

Functions for creating and running database migrations. You should probably be using the pg_migrate executable to run migrations, however these functions are exposed for developers that want to integrate migrations more tightly into their applications or utilities.

Synopsis

Documentation

initializeDb :: IO ()Source

Initializes the database by creating a "schema-migrations" table. This table must exist before running any migrations.

runMigrationsForDirSource

Arguments

:: Handle

Log output (probably stdout)

-> FilePath

Path to directory containing migrations

-> IO ExitCode 

Runs all new migrations in a given directory and dumps the resulting schema to a file "schema.sql" in the migrations directory.

Determining which migrations to run is done by querying the database for the largest version in the schema_migrations table, and choosing all migrations in the given directory with higher versions.

dumpDb :: Handle -> IO ExitCodeSource

Dumps the database schema to the given file handle.

This is a wrapper around the utility pg_dump that comes with postgresql. Therefore, pg_dump must be installed on the system.

defaultMigrationsDir :: FilePathSource

The default relative path containing migrations: "db/migrations"