Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- class (Typeable a, Show a) => Migration a where
- data SomeMigration where
- SomeMigration :: Migration m => m -> SomeMigration
- declareMigration :: QuasiQuoter
- hasqlMover :: forall ms. All Migration ms => IO ()
- performMigrations :: forall migrations. All Migration migrations => MigrationCli -> IO (Either MigrationError ())
- data MigrationCli = MigrationCli {
- db :: MigrationDB
- cmd :: MigrationCmd
- data MigrationCmd
- data MigrationError
- = MigrationCheckError !QueryError
- | MigrationUpError !PendingMigration !QueryError
- | MigrationDownError !UpMigration !QueryError
- | MigrationForceUpError !SomeMigration !QueryError
- | MigrationForceDownError !SomeMigration !QueryError
- | MigrationDivergentDownError !DivergentMigration !QueryError
- | MigrationConnectError !ConnectionError
- | MigrationNothingToRollback
- | MigrationGotDivergents
- | MigrationException !SomeException
- | MigrationNotFound !Text
- data UpMigration = forall m.Migration m => UpMigration {
- migration :: m
- executedAt :: UTCTime
- data PendingMigration = forall m.Migration m => PendingMigration {
- migration :: m
- data DivergentMigration = forall m.Migration m => DivergentMigration {}
- data MigrationDB = forall db.MigrationDB {}
- migrationDBFromSettings :: Settings -> MigrationDB
- hasqlMoverOpts :: Parser MigrationCli
Documentation
class (Typeable a, Show a) => Migration a where Source #
A mapping from a singleton migration name to its up and down SQL
data SomeMigration where Source #
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
MigrationCli | |
|
data MigrationCmd Source #
A command for hasqlMover
MigrateUp | Run pending migrations |
MigrateDown | Rollback a migration |
| |
MigrateStatus | Print the current status |
MigrateForceUp Text | Force the |
MigrateForceDown Text | Force the |
Results
data MigrationError Source #
Checked migrations
data UpMigration Source #
forall m.Migration m => UpMigration | |
|
Instances
Show UpMigration Source # | |
Defined in Hasql.Mover showsPrec :: Int -> UpMigration -> ShowS # show :: UpMigration -> String # showList :: [UpMigration] -> ShowS # |
data PendingMigration Source #
forall m.Migration m => PendingMigration | |
|
Instances
Show PendingMigration Source # | |
Defined in Hasql.Mover showsPrec :: Int -> PendingMigration -> ShowS # show :: PendingMigration -> String # showList :: [PendingMigration] -> ShowS # |
data DivergentMigration Source #
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.
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