hasql-migration

PostgreSQL Schema Migrations

https://github.com/tvh/hasql-migration

Version on this page:0.1.3@rev:1
LTS Haskell 23.0:0.3.1
Stackage Nightly 2024-12-13:0.3.1
Latest on Hackage:0.3.1

See all snapshots hasql-migration appears in

BSD-3-Clause licensed and maintained by Timo von Holtz
This version can be pinned in stack with:hasql-migration-0.1.3@sha256:571db02447c6691e7307dd00ff2a6836ed3bacd1ec95b45f057e30e78b07da94,2819

Module documentation for 0.1.3

PostgreSQL Migrations for Haskell

Build Status

Welcome to hasql-migrations, a tool for helping you with PostgreSQL schema migrations. This is a port of postgresql-simple-migration for use with hasql.

Why?

Database migrations should not be hard. They should be under version control and documented in both your production systems and in your project files.

What?

This library executes SQL/Haskell migration scripts and keeps track of their meta information.

Scripts are be executed exactly once and any changes to scripts will cause a run-time error notifying you of a corrupted database.

The meta information consists of:

  • an MD5 checksum of the executed script to make sure already existing scripts cannot be modified in your production system.
  • a time-stamp of the date of execution so you can easily track when a change happened.

This library also supports migration validation so you can ensure (some) correctness before your application logic kicks in.

How?

TODO

Compilation and Tests

The program is built with the cabal build system. The following command builds the library, the standalone binary and the test package.

cabal configure --enable-tests && cabal build -j

To execute the tests, you need a running PostgreSQL server with an empty database called test. Tests are executed through cabal as follows:

cabal configure --enable-tests && cabal test

To build the project in a cabal sandbox, use the following code:

cabal sandbox init
cabal install -j --only-dependencies --enable-tests --disable-documentation
cabal configure --enable-tests
cabal test

To remove the generated cabal sandbox, use:

cabal sandbox delete

To Do

  • Collect executed scripts and check if already executed scripts have been deleted.