postgresql-migration-persistent
Safe HaskellNone
LanguageHaskell2010

PostgreSQL.Migration.Persistent

Contents

Description

uses Postgres migration to run all found migrations in a transaction. then use persistent to check if the persistent model aligns with what's in the database.

Synopsis

Documentation

runMigrations Source #

Arguments

:: PersistentMigrationOptions

eg defaultOptions

-> Migration

the Automatic migration. usually made with migrateModels and discoverEntities (as splice).

   migrateAll :: Migration
   migrateAll = migrateModels $(discoverEntities)
-> Pool SqlBackend

sql pool, created with for example withPostgresqlPool.

-> IO PMMigrationResult 

Run the given migrations in a single transaction. If the migration fails somehow the transaction is rolled back.

data PMMigrationResult Source #

The result of the postgresql-migration operation.

Constructors

MigrationConsistent 
MigrationRollbackDueTo [Text]

rollback due to persistent inconsistencies

MigrationLibraryError String

some error from the postgres migration libraries

MigrationNotBackedByPg

caused by getSimpleConn returning Nothing

options

defaultOptions Source #

Arguments

:: FilePath

migrations folder, for exmaple "migrations/up"

-> (Either Text Text -> IO ())

the logging options, for example

   (\case
      Left errmsg -> runInIO $ $logTM AlertS $ logStr errmsg
      Right infoMsg -> runInIO $ $logTM InfoS $ logStr infoMsg)
-> PersistentMigrationOptions 

recommended default options for production settnigs

data PersistentMigrationOptions Source #

Usually created with defaultOptions

Constructors

PersistentMigrationOptions 

Fields