Safe Haskell | None |
---|
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.
- initializeDb :: IO ()
- runMigrationsForDir :: Handle -> FilePath -> IO ExitCode
- runRollbackForDir :: FilePath -> IO ExitCode
- dumpDb :: Handle -> IO ExitCode
- defaultMigrationsDir :: FilePath
- data MigrationDetails = MigrationDetails {}
Documentation
initializeDb :: IO ()Source
Initializes the database by creating a "schema-migrations" table. This table must exist before running any migrations.
:: 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: "./dir/migrations"