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 |
Hasql.Migration
Description
A migration library for hasql.
- runMigration :: MigrationCommand -> Transaction (MigrationResult String)
- loadMigrationFromFile :: ScriptName -> FilePath -> IO MigrationCommand
- loadMigrationsFromDirectory :: FilePath -> IO [MigrationCommand]
- data MigrationCommand
- data MigrationResult a
- type ScriptName = String
- type Checksum = Text
- getMigrations :: Transaction [SchemaMigration]
- data SchemaMigration = SchemaMigration {}
Migration actions
runMigration :: MigrationCommand -> Transaction (MigrationResult String) #
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 #
load a migration from script located at the provided
FilePath
.
loadMigrationsFromDirectory :: FilePath -> IO [MigrationCommand] #
Load migrations from SQL scripts in the provided FilePath
in alphabetical order.
Migration types
data MigrationCommand #
MigrationCommand
determines the action of the runMigration
script.
Constructors
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
data MigrationResult a #
A sum-type denoting the result of a migration.
Constructors
MigrationError a | There was an error in script migration. |
MigrationSuccess | All scripts have been executed successfully. |
Instances
Eq a => Eq (MigrationResult a) # | |
Ord a => Ord (MigrationResult a) # | |
Read a => Read (MigrationResult a) # | |
Show a => Show (MigrationResult a) # | |
type ScriptName = String #
The name of a script. Typically the filename or a custom name when using Haskell migrations.
Migration result actions
getMigrations :: Transaction [SchemaMigration] #
Produces a list of all executed SchemaMigration
s.
Migration result types
data SchemaMigration #
A product type representing a single, executed SchemaMigration
.
Constructors
SchemaMigration | |
Fields
|
Instances