{-# LANGUAGE OverloadedStrings #-}
module Database.PostgreSQL.Simple.Migration.V1Compat
(
runMigration
, runMigrations
, V2.sequenceMigrations
, MigrationContext(..)
, V2.MigrationCommand(..)
, V2.MigrationResult(..)
, V2.ScriptName
, V2.Checksum
, V2.getMigrations
, V2.SchemaMigration(..)
) where
import Database.PostgreSQL.Simple (Connection)
import qualified Database.PostgreSQL.Simple.Migration as V2
runMigration :: MigrationContext -> IO (V2.MigrationResult [Char])
runMigration :: MigrationContext -> IO (MigrationResult [Char])
runMigration (MigrationContext MigrationCommand
cmd Bool
verbose Connection
con) = Bool
-> Connection -> [MigrationCommand] -> IO (MigrationResult [Char])
runMigrations Bool
verbose Connection
con [MigrationCommand
cmd]
runMigrations
:: Bool
-> Connection
-> [V2.MigrationCommand]
-> IO (V2.MigrationResult String)
runMigrations :: Bool
-> Connection -> [MigrationCommand] -> IO (MigrationResult [Char])
runMigrations Bool
verbose Connection
con [MigrationCommand]
commands = do
let opts :: MigrationOptions
opts = MigrationOptions
V2.defaultOptions
{ optVerbose :: Verbosity
V2.optVerbose = if Bool
verbose then Verbosity
V2.Verbose else Verbosity
V2.Quiet
, optTableName :: ByteString
V2.optTableName = ByteString
"schema_migrations"
, optTransactionControl :: TransactionControl
V2.optTransactionControl = TransactionControl
V2.NoNewTransaction
}
Connection
-> MigrationOptions
-> [MigrationCommand]
-> IO (MigrationResult [Char])
V2.runMigrations Connection
con MigrationOptions
opts [MigrationCommand]
commands
data MigrationContext = MigrationContext
{ MigrationContext -> MigrationCommand
migrationContextCommand :: V2.MigrationCommand
, MigrationContext -> Bool
migrationContextVerbose :: Bool
, MigrationContext -> Connection
migrationContextConnection :: Connection
}