postgresql-migration-persistent 1.0.0 → 1.1.0
raw patch · 3 files changed
+25/−9 lines, 3 files
Files
- Changelog.md +5/−0
- postgresql-migration-persistent.cabal +1/−1
- src/PostgreSQL/Migration/Persistent.hs +19/−8
Changelog.md view
@@ -1,5 +1,10 @@ # Change log for postgresql-migration-persistent project +## Version 1.1.0+Drop the migration table option,+this is already set by the underlying library.+Add more haddock linking.+ ## Version 1.0.0 import the code
postgresql-migration-persistent.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0 name: postgresql-migration-persistent-version: 1.0.0+version: 1.1.0 homepage: https://github.com/jappeace/postgresql-migration-persistent#readme bug-reports: https://github.com/jappeace/postgresql-migration-persistent/issues author: Jappie Klooster, Jean-Paul Calderone
src/PostgreSQL/Migration/Persistent.hs view
@@ -14,6 +14,8 @@ ) where +import qualified Data.Text.Encoding as Text+import qualified Data.Text as Text import Control.Monad.IO.Class (liftIO) import Control.Monad.Reader (ReaderT (..), asks) import Data.Pool (Pool)@@ -32,7 +34,7 @@ -- | the logging options, for example -- -- @- -- (\case+ -- (\\case -- Left errmsg -> runInIO $ $logTM AlertS $ logStr errmsg -- Right infoMsg -> runInIO $ $logTM InfoS $ logStr infoMsg) -- @@@ -47,8 +49,7 @@ -- NB we do the transaction around the entire thing Migration.optTransactionControl = Migration.NoNewTransaction },- pmoMigrationSource = Migration.MigrationDirectory filepath,- pmoSchemaMigrationTableName = "schema_migrations"+ pmoMigrationSource = Migration.MigrationDirectory filepath } -- | The result of the postgresql-migration operation.@@ -62,10 +63,15 @@ MigrationNotBackedByPg deriving stock (Show, Eq) +-- | Usually created with 'defaultOptions' data PersistentMigrationOptions = PersistentMigrationOptions { pmoMigrationOptions :: Migration.MigrationOptions,- pmoMigrationSource :: Migration.MigrationCommand,- pmoSchemaMigrationTableName :: String+ -- | by default this is set to load a folder with 'Migration.MigrationDirectory'.+ -- but certain poeple had trouble with that as it includes all files.+ -- so with this option you can make your own directory parsing+ -- and just put the command(s) in here.+ -- note 'Migration.MigrationCommands'.+ pmoMigrationSource :: Migration.MigrationCommand } -- | Run the given migrations in a single transaction. If the migration fails@@ -73,9 +79,14 @@ runMigrations :: -- | eg 'defaultOptions' PersistentMigrationOptions ->- -- | the Automatic migration. eg 'migrateAll', or migrateModels $(discoverEntities). note this is+ -- | the Automatic migration. usually made with 'Database.Persist.TH.migrateModels' and 'Database.Persist.TH.discoverEntities' (as splice).+ --+ -- @+ -- migrateAll :: Migration+ -- migrateAll = migrateModels $(discoverEntities)+ -- @ Migration ->- -- | sql pool, created with for example 'withPostgresqlPool'.+ -- | sql pool, created with for example 'Database.Persist.Postgresql.withPostgresqlPool'. Pool SqlBackend -> IO PMMigrationResult runMigrations config migrateAll pool =@@ -94,7 +105,7 @@ runMigrationCommands :: PersistentMigrationOptions -> Connection -> ReaderT SqlBackend IO (Migration.MigrationResult String) runMigrationCommands options conn = do- initialized <- liftIO $ Migration.existsTable conn $ pmoSchemaMigrationTableName options+ initialized <- liftIO $ Migration.existsTable conn $ Text.unpack $ Text.decodeUtf8 $ Migration.optTableName $ pmoMigrationOptions options let migrations = if initialized then [pmoMigrationSource options]