Copyright | (c) 2016 Timo von Holtz <tvh@tvholtz.de> (c) 2014 Andreas Meingast <ameingast@gmail.com> |
---|---|
License | BSD-style |
Maintainer | tvh@tvholtz.de |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
A migration library for hasql.
Synopsis
- runMigration :: MigrationCommand -> Transaction (Maybe MigrationError)
- loadMigrationFromFile :: ScriptName -> FilePath -> IO MigrationCommand
- loadMigrationsFromDirectory :: FilePath -> IO [MigrationCommand]
- data MigrationCommand
- data MigrationError
- type ScriptName = String
- type Checksum = Text
- getMigrations :: Transaction [SchemaMigration]
- data SchemaMigration = SchemaMigration {}
Migration actions
runMigration :: MigrationCommand -> Transaction (Maybe MigrationError) Source #
Executes a MigrationCommand
.
Returns MigrationSuccess
if the provided MigrationCommand
executes
without error. If an error occurs, execution is stopped and
a MigrationError
is returned.
loadMigrationFromFile :: ScriptName -> FilePath -> IO MigrationCommand Source #
load a migration from script located at the provided
FilePath
.
loadMigrationsFromDirectory :: FilePath -> IO [MigrationCommand] Source #
Load migrations from SQL scripts in the provided FilePath
in alphabetical order.
Migration types
data MigrationCommand Source #
MigrationCommand
determines the action of the runMigration
script.
MigrationInitialization | Initializes the database with a helper table containing meta information. |
MigrationScript ScriptName ByteString | Executes a migration based on the provided bytestring. |
MigrationValidation MigrationCommand | Validates the provided MigrationCommand. |
Instances
Eq MigrationCommand Source # | |
Defined in Hasql.Migration (==) :: MigrationCommand -> MigrationCommand -> Bool # (/=) :: MigrationCommand -> MigrationCommand -> Bool # | |
Ord MigrationCommand Source # | |
Defined in Hasql.Migration compare :: MigrationCommand -> MigrationCommand -> Ordering # (<) :: MigrationCommand -> MigrationCommand -> Bool # (<=) :: MigrationCommand -> MigrationCommand -> Bool # (>) :: MigrationCommand -> MigrationCommand -> Bool # (>=) :: MigrationCommand -> MigrationCommand -> Bool # max :: MigrationCommand -> MigrationCommand -> MigrationCommand # min :: MigrationCommand -> MigrationCommand -> MigrationCommand # | |
Read MigrationCommand Source # | |
Defined in Hasql.Migration | |
Show MigrationCommand Source # | |
Defined in Hasql.Migration showsPrec :: Int -> MigrationCommand -> ShowS # show :: MigrationCommand -> String # showList :: [MigrationCommand] -> ShowS # |
data MigrationError Source #
Errors that could occur when a migration is validated or performed
Instances
Eq MigrationError Source # | |
Defined in Hasql.Migration (==) :: MigrationError -> MigrationError -> Bool # (/=) :: MigrationError -> MigrationError -> Bool # | |
Ord MigrationError Source # | |
Defined in Hasql.Migration compare :: MigrationError -> MigrationError -> Ordering # (<) :: MigrationError -> MigrationError -> Bool # (<=) :: MigrationError -> MigrationError -> Bool # (>) :: MigrationError -> MigrationError -> Bool # (>=) :: MigrationError -> MigrationError -> Bool # max :: MigrationError -> MigrationError -> MigrationError # min :: MigrationError -> MigrationError -> MigrationError # | |
Read MigrationError Source # | |
Defined in Hasql.Migration readsPrec :: Int -> ReadS MigrationError # readList :: ReadS [MigrationError] # | |
Show MigrationError Source # | |
Defined in Hasql.Migration showsPrec :: Int -> MigrationError -> ShowS # show :: MigrationError -> String # showList :: [MigrationError] -> ShowS # |
type ScriptName = String Source #
The name of a script. Typically the filename or a custom name when using Haskell migrations.
Migration result actions
getMigrations :: Transaction [SchemaMigration] Source #
Produces a list of all executed SchemaMigration
s.
Migration result types
data SchemaMigration Source #
A product type representing a single, executed SchemaMigration
.
SchemaMigration | |
|
Instances
Eq SchemaMigration Source # | |
Defined in Hasql.Migration (==) :: SchemaMigration -> SchemaMigration -> Bool # (/=) :: SchemaMigration -> SchemaMigration -> Bool # | |
Ord SchemaMigration Source # | |
Defined in Hasql.Migration compare :: SchemaMigration -> SchemaMigration -> Ordering # (<) :: SchemaMigration -> SchemaMigration -> Bool # (<=) :: SchemaMigration -> SchemaMigration -> Bool # (>) :: SchemaMigration -> SchemaMigration -> Bool # (>=) :: SchemaMigration -> SchemaMigration -> Bool # max :: SchemaMigration -> SchemaMigration -> SchemaMigration # min :: SchemaMigration -> SchemaMigration -> SchemaMigration # | |
Read SchemaMigration Source # | |
Defined in Hasql.Migration | |
Show SchemaMigration Source # | |
Defined in Hasql.Migration showsPrec :: Int -> SchemaMigration -> ShowS # show :: SchemaMigration -> String # showList :: [SchemaMigration] -> ShowS # |