-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | PostgreSQL Schema Migrations
--   
--   A PostgreSQL-simple schema migration utility
@package hasql-migration
@version 0.1.3


-- | A collection of utilites for database migrations.
module Hasql.Migration.Util

-- | Checks if the table with the given name exists in the database.
existsTable :: Text -> Transaction Bool


-- | A migration library for hasql.
module Hasql.Migration

-- | Executes a <a>MigrationCommand</a>.
--   
--   Returns <a>MigrationSuccess</a> if the provided
--   <a>MigrationCommand</a> executes without error. If an error occurs,
--   execution is stopped and a <a>MigrationError</a> is returned.
runMigration :: MigrationCommand -> Transaction (MigrationResult String)

-- | load a migration from script located at the provided <a>FilePath</a>.
loadMigrationFromFile :: ScriptName -> FilePath -> IO MigrationCommand

-- | Load migrations from SQL scripts in the provided <a>FilePath</a> in
--   alphabetical order.
loadMigrationsFromDirectory :: FilePath -> IO [MigrationCommand]

-- | <a>MigrationCommand</a> determines the action of the
--   <a>runMigration</a> script.
data MigrationCommand

-- | Initializes the database with a helper table containing meta
--   information.
MigrationInitialization :: MigrationCommand

-- | Executes a migration based on the provided bytestring.
MigrationScript :: ScriptName -> ByteString -> MigrationCommand

-- | Validates the provided MigrationCommand.
MigrationValidation :: 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 = Text

-- | Produces a list of all executed <a>SchemaMigration</a>s.
getMigrations :: Transaction [SchemaMigration]

-- | A product type representing a single, executed <a>SchemaMigration</a>.
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.Read.Read Hasql.Migration.SchemaMigration
instance GHC.Classes.Eq Hasql.Migration.SchemaMigration
instance GHC.Show.Show Hasql.Migration.SchemaMigration
instance GHC.Classes.Ord a => GHC.Classes.Ord (Hasql.Migration.MigrationResult a)
instance GHC.Read.Read a => GHC.Read.Read (Hasql.Migration.MigrationResult a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Hasql.Migration.MigrationResult a)
instance GHC.Show.Show a => GHC.Show.Show (Hasql.Migration.MigrationResult a)
instance GHC.Classes.Ord Hasql.Migration.CheckScriptResult
instance GHC.Read.Read Hasql.Migration.CheckScriptResult
instance GHC.Classes.Eq Hasql.Migration.CheckScriptResult
instance GHC.Show.Show Hasql.Migration.CheckScriptResult
instance GHC.Classes.Ord Hasql.Migration.MigrationCommand
instance GHC.Read.Read Hasql.Migration.MigrationCommand
instance GHC.Classes.Eq Hasql.Migration.MigrationCommand
instance GHC.Show.Show Hasql.Migration.MigrationCommand
instance GHC.Classes.Ord Hasql.Migration.SchemaMigration
