-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | PostgreSQL Schema Migrations -- -- A PostgreSQL-simple schema migration utility @package postgresql-migration @version 0.2.1.4 -- | A collection of utilites for database migrations. module Database.PostgreSQL.Simple.Util -- | Checks if the table with the given name exists in the database. existsTable :: Connection -> String -> IO Bool -- | Executes the given IO monad inside a transaction and performs a -- roll-back afterwards (even if exceptions occur). withTransactionRolledBack :: Connection -> IO a -> IO a -- | A migration library for postgresql-simple. -- -- For usage, see Readme.markdown. module Database.PostgreSQL.Simple.Migration defaultOptions :: MigrationOptions -- | 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. runMigration :: Connection -> MigrationOptions -> MigrationCommand -> IO (MigrationResult String) -- | Execute a sequence of migrations -- -- Returns MigrationSuccess if all of the provided -- MigrationCommands execute without error. If an error occurs, -- execution is stopped and the MigrationError is returned. runMigrations :: Connection -> MigrationOptions -> [MigrationCommand] -> IO (MigrationResult String) -- | Run a sequence of contexts, stopping on the first failure sequenceMigrations :: Monad m => [m (MigrationResult e)] -> m (MigrationResult e) -- | The checksum type of a migration script. type Checksum = ByteString data MigrationOptions MigrationOptions :: !Verbosity -> !ByteString -> !Either Text Text -> IO () -> !TransactionControl -> MigrationOptions -- | Verbosity of the library. [optVerbose] :: MigrationOptions -> !Verbosity -- | The name of the table that stores the migrations, usually -- "schema_migrations" [optTableName] :: MigrationOptions -> !ByteString -- | Logger. Either indicates log level, Left for an error -- message and Right for an info message. [optLogWriter] :: MigrationOptions -> !Either Text Text -> IO () -- | If/when transactions should be started [optTransactionControl] :: MigrationOptions -> !TransactionControl -- | MigrationCommand determines the action of the -- runMigration script. data MigrationCommand -- | Initializes the database with a helper table containing meta -- information. MigrationInitialization :: MigrationCommand -- | Executes migrations based on SQL scripts in the provided -- FilePath in alphabetical order. MigrationDirectory :: FilePath -> MigrationCommand -- | Executes a migration based on script located at the provided -- FilePath. MigrationFile :: ScriptName -> FilePath -> MigrationCommand -- | Executes a migration based on the provided bytestring. MigrationScript :: ScriptName -> ByteString -> MigrationCommand -- | Validates that the provided MigrationCommand has been executed. MigrationValidation :: MigrationCommand -> MigrationCommand -- | Performs a series of MigrationCommands in sequence. MigrationCommands :: [MigrationCommand] -> MigrationCommand -- | A sum-type denoting the result of a migration. data MigrationResult a -- | There was an error in script migration. MigrationError :: a -> MigrationResult a -- | All scripts have been executed successfully. MigrationSuccess :: MigrationResult a -- | The name of a script. Typically the filename or a custom name when -- using Haskell migrations. type ScriptName = String -- | 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 data TransactionControl -- | No new transaction will be started. Up to the caller to decide if the -- run is in a transaction or not NoNewTransaction :: TransactionControl -- | Call withTransaction once for the entire -- MigrationCommand TransactionPerRun :: TransactionControl -- | Call withTransaction once for each step in a -- MigrationCommand (i.e. new transaction per script) TransactionPerStep :: TransactionControl data Verbosity Verbose :: Verbosity Quiet :: Verbosity -- | Produces a list of all executed SchemaMigrations in the default -- schema_migrations table getMigrations :: Connection -> IO [SchemaMigration] -- | Produces a list of all executed SchemaMigrations. getMigrations' :: Connection -> ByteString -> IO [SchemaMigration] -- | A product type representing a single, executed SchemaMigration. data SchemaMigration SchemaMigration :: ByteString -> Checksum -> LocalTime -> SchemaMigration -- | The name of the executed migration. [schemaMigrationName] :: SchemaMigration -> ByteString -- | The calculated MD5 checksum of the executed script. [schemaMigrationChecksum] :: SchemaMigration -> Checksum -- | A timestamp without timezone of the date of execution of the script. [schemaMigrationExecutedAt] :: SchemaMigration -> LocalTime instance GHC.Classes.Ord Database.PostgreSQL.Simple.Migration.MigrationCommand instance GHC.Read.Read Database.PostgreSQL.Simple.Migration.MigrationCommand instance GHC.Classes.Eq Database.PostgreSQL.Simple.Migration.MigrationCommand instance GHC.Show.Show Database.PostgreSQL.Simple.Migration.MigrationCommand instance GHC.Show.Show a => GHC.Show.Show (Database.PostgreSQL.Simple.Migration.ExpectedVsActual a) instance GHC.Show.Show Database.PostgreSQL.Simple.Migration.CheckScriptResult instance Data.Traversable.Traversable Database.PostgreSQL.Simple.Migration.MigrationResult instance Data.Foldable.Foldable Database.PostgreSQL.Simple.Migration.MigrationResult instance GHC.Base.Functor Database.PostgreSQL.Simple.Migration.MigrationResult instance GHC.Classes.Ord a => GHC.Classes.Ord (Database.PostgreSQL.Simple.Migration.MigrationResult a) instance GHC.Read.Read a => GHC.Read.Read (Database.PostgreSQL.Simple.Migration.MigrationResult a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Database.PostgreSQL.Simple.Migration.MigrationResult a) instance GHC.Show.Show a => GHC.Show.Show (Database.PostgreSQL.Simple.Migration.MigrationResult a) instance GHC.Classes.Eq Database.PostgreSQL.Simple.Migration.Verbosity instance GHC.Show.Show Database.PostgreSQL.Simple.Migration.Verbosity instance GHC.Show.Show Database.PostgreSQL.Simple.Migration.TransactionControl instance GHC.Read.Read Database.PostgreSQL.Simple.Migration.SchemaMigration instance GHC.Classes.Eq Database.PostgreSQL.Simple.Migration.SchemaMigration instance GHC.Show.Show Database.PostgreSQL.Simple.Migration.SchemaMigration instance GHC.Classes.Ord Database.PostgreSQL.Simple.Migration.SchemaMigration instance Database.PostgreSQL.Simple.FromRow.FromRow Database.PostgreSQL.Simple.Migration.SchemaMigration instance Database.PostgreSQL.Simple.ToRow.ToRow Database.PostgreSQL.Simple.Migration.SchemaMigration instance GHC.Base.Semigroup Database.PostgreSQL.Simple.Migration.MigrationCommand instance GHC.Base.Monoid Database.PostgreSQL.Simple.Migration.MigrationCommand -- | A migration library for postgresql-simple. -- -- For usage, see Readme.markdown. module Database.PostgreSQL.Simple.Migration.V1Compat runMigration :: MigrationContext -> IO (MigrationResult [Char]) runMigrations :: Bool -> Connection -> [MigrationCommand] -> IO (MigrationResult String) -- | Run a sequence of contexts, stopping on the first failure sequenceMigrations :: Monad m => [m (MigrationResult e)] -> m (MigrationResult e) -- | The MigrationContext provides an execution context for -- migrations. data MigrationContext MigrationContext :: MigrationCommand -> Bool -> Connection -> MigrationContext -- | The action that will be performed by runMigration [migrationContextCommand] :: MigrationContext -> MigrationCommand -- | Verbosity of the library. [migrationContextVerbose] :: MigrationContext -> Bool -- | The PostgreSQL connection to use for migrations. [migrationContextConnection] :: MigrationContext -> Connection -- | MigrationCommand determines the action of the -- runMigration script. data MigrationCommand -- | Initializes the database with a helper table containing meta -- information. MigrationInitialization :: MigrationCommand -- | Executes migrations based on SQL scripts in the provided -- FilePath in alphabetical order. MigrationDirectory :: FilePath -> MigrationCommand -- | Executes a migration based on script located at the provided -- FilePath. MigrationFile :: ScriptName -> FilePath -> MigrationCommand -- | Executes a migration based on the provided bytestring. MigrationScript :: ScriptName -> ByteString -> MigrationCommand -- | Validates that the provided MigrationCommand has been executed. MigrationValidation :: MigrationCommand -> MigrationCommand -- | Performs a series of MigrationCommands in sequence. MigrationCommands :: [MigrationCommand] -> MigrationCommand -- | A sum-type denoting the result of a migration. data MigrationResult a -- | There was an error in script migration. MigrationError :: a -> MigrationResult a -- | All scripts have been executed successfully. MigrationSuccess :: MigrationResult a -- | The name of a script. Typically the filename or a custom name when -- using Haskell migrations. type ScriptName = String -- | The checksum type of a migration script. type Checksum = ByteString -- | Produces a list of all executed SchemaMigrations in the default -- schema_migrations table getMigrations :: Connection -> IO [SchemaMigration] -- | A product type representing a single, executed SchemaMigration. data SchemaMigration SchemaMigration :: ByteString -> Checksum -> LocalTime -> SchemaMigration -- | The name of the executed migration. [schemaMigrationName] :: SchemaMigration -> ByteString -- | The calculated MD5 checksum of the executed script. [schemaMigrationChecksum] :: SchemaMigration -> Checksum -- | A timestamp without timezone of the date of execution of the script. [schemaMigrationExecutedAt] :: SchemaMigration -> LocalTime