| Copyright | (c) 2014 Andreas Meingast <ameingast@gmail.com> |
|---|---|
| License | BSD-style |
| Maintainer | ameingast@gmail.com |
| Stability | experimental |
| Portability | GHC |
| Safe Haskell | None |
| Language | Haskell2010 |
Database.PostgreSQL.Simple.Migration
Description
A migration library for postgresql-simple.
For usage, see Readme.markdown.
- runMigration :: MigrationContext -> IO (MigrationResult String)
- data MigrationContext = MigrationContext {}
- data MigrationCommand
- data MigrationResult a
- type ScriptName = String
- type Checksum = ByteString
- getMigrations :: Connection -> IO [SchemaMigration]
- data SchemaMigration = SchemaMigration {}
Migration actions
runMigration :: MigrationContext -> IO (MigrationResult String) Source #
Executes migrations inside the provided MigrationContext.
Returns MigrationSuccess if the provided MigrationCommand executes
without error. If an error occurs, execution is stopped and
a MigrationError is returned.
It is recommended to wrap runMigration inside a database transaction.
Migration types
data MigrationContext Source #
The MigrationContext provides an execution context for migrations.
Constructors
| MigrationContext | |
Fields
| |
data MigrationCommand Source #
MigrationCommand determines the action of the runMigration script.
Constructors
| MigrationInitialization | Initializes the database with a helper table containing meta information. |
| MigrationDirectory FilePath | Executes migrations based on SQL scripts in the provided |
| MigrationFile ScriptName FilePath | Executes a migration based on script located at the provided
|
| MigrationScript ScriptName ByteString | Executes a migration based on the provided bytestring. |
| MigrationValidation MigrationCommand | Validates the provided MigrationCommand. |
data MigrationResult a Source #
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) Source # | |
| Ord a => Ord (MigrationResult a) Source # | |
| Read a => Read (MigrationResult a) Source # | |
| Show a => Show (MigrationResult a) Source # | |
type ScriptName = String Source #
The name of a script. Typically the filename or a custom name when using Haskell migrations.
type Checksum = ByteString Source #
The checksum type of a migration script.
Migration result actions
getMigrations :: Connection -> IO [SchemaMigration] Source #
Produces a list of all executed SchemaMigrations.
Migration result types
data SchemaMigration Source #
A product type representing a single, executed SchemaMigration.
Constructors
| SchemaMigration | |
Fields
| |