Copyright | (c) 2014 Andreas Meingast <ameingast@gmail.com> |
---|---|
License | BSD-style |
Maintainer | ameingast@gmail.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
A migration library for postgresql-simple.
For usage, see Readme.markdown.
Synopsis
- defaultOptions :: MigrationOptions
- runMigration :: Connection -> MigrationOptions -> MigrationCommand -> IO (MigrationResult String)
- runMigrations :: Connection -> MigrationOptions -> [MigrationCommand] -> IO (MigrationResult String)
- sequenceMigrations :: Monad m => [m (MigrationResult e)] -> m (MigrationResult e)
- type Checksum = ByteString
- data MigrationOptions = MigrationOptions {
- optVerbose :: !Verbosity
- optTableName :: !ByteString
- optLogWriter :: !(Either Text Text -> IO ())
- optTransactionControl :: !TransactionControl
- data MigrationCommand
- data MigrationResult a
- type ScriptName = String
- data TransactionControl
- data Verbosity
- getMigrations :: Connection -> IO [SchemaMigration]
- getMigrations' :: Connection -> ByteString -> IO [SchemaMigration]
- data SchemaMigration = SchemaMigration {}
Migration actions
runMigration :: Connection -> MigrationOptions -> MigrationCommand -> 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.
:: Connection | The postgres connection to use |
-> MigrationOptions | The options for this migration |
-> [MigrationCommand] | The commands to run |
-> IO (MigrationResult String) |
Execute a sequence of migrations
Returns MigrationSuccess
if all of the provided MigrationCommand
s
execute without error. If an error occurs, execution is stopped and the
MigrationError
is returned.
sequenceMigrations :: Monad m => [m (MigrationResult e)] -> m (MigrationResult e) Source #
Run a sequence of contexts, stopping on the first failure
Migration types
type Checksum = ByteString Source #
The checksum type of a migration script.
data MigrationOptions Source #
MigrationOptions | |
|
data MigrationCommand Source #
MigrationCommand
determines the action of the runMigration
script.
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 that the provided MigrationCommand has been executed. |
MigrationCommands [MigrationCommand] | Performs a series of |
Instances
data MigrationResult a Source #
A sum-type denoting the result of a migration.
MigrationError a | There was an error in script migration. |
MigrationSuccess | All scripts have been executed successfully. |
Instances
type ScriptName = String Source #
The name of a script. Typically the filename or a custom name when using Haskell migrations.
data TransactionControl Source #
Determines how transactions are handled Its is recommened to use transaction when running migrations Certain actions require a transaction per script, if you are doing this use TransactionPerStep If you want a single transaction for all migrations use TransactionPerRun If you do not want a transaction, or are using an existing transaction then use NoNewTransaction
NoNewTransaction | No new transaction will be started. Up to the caller to decide if the run is in a transaction or not |
TransactionPerRun | Call |
TransactionPerStep | Call |
Instances
Show TransactionControl Source # | |
Defined in Database.PostgreSQL.Simple.Migration showsPrec :: Int -> TransactionControl -> ShowS # show :: TransactionControl -> String # showList :: [TransactionControl] -> ShowS # |
Migration result actions
getMigrations :: Connection -> IO [SchemaMigration] Source #
Produces a list of all executed SchemaMigration
s in the default schema_migrations table
getMigrations' :: Connection -> ByteString -> IO [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 | |
|