hasql-mover-0.1.1: Hasql migrations library
Safe HaskellSafe-Inferred
LanguageGHC2021

Hasql.Mover

Synopsis

Documentation

class (Typeable a, Show a) => Migration a where Source #

A mapping from a singleton migration name to its up and down SQL

Methods

migration :: a Source #

The name for this migration

up :: a -> Text Source #

How to run this migration

down :: a -> Text Source #

How to rollback this migration

data SomeMigration where Source #

Constructors

SomeMigration :: Migration m => m -> SomeMigration 

Declaration

declareMigration :: QuasiQuoter Source #

Declare a migration with a nice syntax.

[declareMigration|
name = AddFoo

[up]
CREATE TABLE foo();

[down]
DROP TABLE foo();
|]

type Migrations = '[BaseMigration, AddFoo]

Checking and running migrations

Main functions

hasqlMover :: forall ms. All Migration ms => IO () Source #

Main function for running hasql-mover migrations

Example usage:

[declareMigration|
name = V0

[up]
CREATE TABLE foo ();

[down]
DROP TABLE foo CASCADE;
|]

type Migrations = '[V0]

main :: IO ()
main = hasqlMoverMain @Migrations

performMigrations :: forall migrations. All Migration migrations => MigrationCli -> IO (Either MigrationError ()) Source #

Perform the migrations according to some MigrationCli

Options

data MigrationCli Source #

Options to supply to hasqlMover: a database connection and what migration command to run

Constructors

MigrationCli 

data MigrationCmd Source #

A command for hasqlMover

Constructors

MigrateUp

Run pending migrations

MigrateDown

Rollback a migration

Fields

MigrateStatus

Print the current status

MigrateForceUp Text

Force the up of a migration to run, regardless of its status or position in the migrations list

MigrateForceDown Text

Force the down of a migration to run, regardless of its status or position in the migrations list

Results

Checked migrations

data UpMigration Source #

Constructors

forall m.Migration m => UpMigration 

Fields

Instances

Instances details
Show UpMigration Source # 
Instance details

Defined in Hasql.Mover

data PendingMigration Source #

Constructors

forall m.Migration m => PendingMigration 

Fields

Instances

Instances details
Show PendingMigration Source # 
Instance details

Defined in Hasql.Mover

data DivergentMigration Source #

Constructors

forall m.Migration m => DivergentMigration 

Settings

data MigrationDB Source #

Encapsulates a way to run a hasql session; it could be through a pool, or through a connection directly.

Constructors

forall db. MigrationDB 

Fields

migrationDBFromSettings :: Settings -> MigrationDB Source #

Create a MigrationDB from a hasql settings - a PostgreSQL connection string as of writing

Integrating into an existing "main"

hasqlMoverOpts :: Parser MigrationCli Source #

optparse-applicative options for hasql-mover; use hasqlMover to then run the parsed options