postgresql-migration 0.2.1.6 → 0.2.1.7
raw patch · 4 files changed
+38/−36 lines, 4 filesdep +cryptohash-md5dep −cryptohashdep ~base64-bytestringdep ~bytestringdep ~directory
Dependencies added: cryptohash-md5
Dependencies removed: cryptohash
Dependency ranges changed: base64-bytestring, bytestring, directory, filepath, hspec, postgresql-simple, text, time
Files
- Changelog.markdown +3/−0
- Readme.markdown +4/−6
- postgresql-migration.cabal +21/−20
- src/Database/PostgreSQL/Simple/Migration.hs +10/−10
Changelog.markdown view
@@ -1,5 +1,8 @@ # Changelog +## Unreleased+* Switch from deprecated cryptohash dependency to cryptohash-md5 + ## 0.2.1.0 * Forked & renamed to postgresql-migration * Support for changing the schema_migration table name
Readme.markdown view
@@ -28,7 +28,7 @@ This library executes SQL/Haskell migration scripts and keeps track of their meta information. -Scripts are be executed exactly once and any changes to scripts will cause+Scripts are executed exactly once and any changes to scripts will cause a run-time error notifying you of a corrupted database. The meta information consists of:@@ -140,7 +140,7 @@ ### Options -The `runMigration` and `runMigration` functions take an options record that let you+The `runMigration` and `runMigrations` functions take an options record that let you set the following - `optVerbose`: Is verbose logging enabled or not@@ -165,7 +165,7 @@ ```bash cabal configure --enable-tests -PGHOST=localhost PGDATABASE=test make-cabal test+PGHOST=localhost PGDATABASE=test make cabal-test ``` To build with stack use the following command@@ -181,7 +181,7 @@ ``` NB note that the **psql** test argument must be set for the test suite to run. This is so that other CI environments like-stackage or nix that wont have a running test psql instance will not fail on these tests+stackage or nix that won't have a running test psql instance will not fail on these tests # Changes from the original postgresql-simple-migration (version 0.1)@@ -238,5 +238,3 @@ ``` That is all that needs to change. Your migrations scripts etc all remain as is.--
postgresql-migration.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: postgresql-migration-version: 0.2.1.6+version: 0.2.1.7 synopsis: PostgreSQL Schema Migrations homepage: https://github.com/andrevdm/postgresql-migration Bug-reports: https://github.com/andrevdm/postgresql-migration/issues@@ -12,7 +12,7 @@ category: Database build-type: Simple description: A PostgreSQL-simple schema migration utility-tested-with: GHC==9.2.4, GHC==9.0.1, GHC==8.8.4, GHC==8.6.5, GHC==8.4.4+tested-with: GHC==9.2.4, GHC==9.0.1, GHC==8.8.4, GHC==8.6.5, GHC==8.4.4, GHC==9.6.1 extra-source-files: License Readme.markdown@@ -36,7 +36,7 @@ ghc-options: -fwrite-ide-info -hiedir=.hie common common-ghc-options- ghc-options: -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Wcompat -Wredundant-constraints -Wnoncanonical-monad-instances -Widentities -fhide-source-paths -Wpartial-fields -fhide-source-paths -freverse-errors+ ghc-options: -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Wcompat -Wredundant-constraints -Wnoncanonical-monad-instances -Widentities -Wpartial-fields -fhide-source-paths -freverse-errors library@@ -54,15 +54,16 @@ hs-source-dirs: src default-language: Haskell2010 build-depends: base >= 4.9 && < 5.0- , base64-bytestring >= 1.0- , bytestring >= 0.10- , cryptohash >= 0.11- , directory >= 1.2- , filepath >= 1.4.1.0- , postgresql-simple >= 0.4- , time >= 1.4- , text >= 1.2 || ^>=2.0+ , base64-bytestring >= 1.0 && < 1.3+ , bytestring >= 0.10 && < 0.12+ , cryptohash-md5 >= 0.11 && < 0.12+ , directory >= 1.2 && < 1.4+ , filepath >= 1.4.1.0 && < 1.5+ , postgresql-simple >= 0.4 && < 0.7+ , time >= 1.4 && < 1.13+ , text >= 1.2 && < 2.1 + executable migrate import: common-options import: common-ghc-options@@ -78,12 +79,12 @@ build-depends: postgresql-migration , base >= 4.9 && < 5.0 , base64-bytestring >= 1.0- , bytestring >= 0.10- , cryptohash >= 0.11- , directory >= 1.2- , postgresql-simple >= 0.4- , time >= 1.4- , text >= 1.2 || ^>=2.0+ , bytestring >= 0.10 && < 0.12+ , cryptohash-md5 >= 0.11 && < 0.12+ , directory >= 1.2 && < 1.4+ , postgresql-simple >= 0.4 && < 0.7+ , time >= 1.4 && < 1.13+ , text >= 1.2 && < 2.1 test-suite tests import: common-options@@ -101,6 +102,6 @@ type: exitcode-stdio-1.0 build-depends: postgresql-migration , base >= 4.9 && < 5.0- , bytestring >= 0.10- , postgresql-simple >= 0.4- , hspec >= 2.2+ , bytestring >= 0.10 && < 0.12+ , postgresql-simple >= 0.4 && < 0.7+ , hspec >= 2.2 && < 2.12
src/Database/PostgreSQL/Simple/Migration.hs view
@@ -46,7 +46,7 @@ import qualified Data.ByteString.Char8 as BS8 (unpack) import qualified Data.ByteString.Base64 as B64 (encode) import Data.Functor ((<&>))-import Data.List (isPrefixOf, sort)+import Data.List (sort) import Data.Time (LocalTime) import qualified Data.Text as T import qualified Data.Text.IO as T (putStrLn, hPutStrLn)@@ -64,11 +64,11 @@ import Database.PostgreSQL.Simple.ToRow (ToRow (..)) import Database.PostgreSQL.Simple.Types (Query (..)) import Database.PostgreSQL.Simple.Util (existsTable)-import System.Directory (getDirectoryContents)+import System.Directory (listDirectory) import System.FilePath ((</>)) import System.IO (stderr) --- | Executes migrations inside the provided 'MigrationContext'.+-- | Executes migrations using the provided 'MigrationOptions'. -- -- Returns 'MigrationSuccess' if the provided 'MigrationCommand' executes -- without error. If an error occurs, execution is stopped and@@ -156,7 +156,7 @@ -- | Lists all files in the given 'FilePath' 'dir' in alphabetical order. scriptsInDirectory :: FilePath -> IO [String] scriptsInDirectory dir =- getDirectoryContents dir <&> (sort . filter (\x -> not $ "." `isPrefixOf` x))+ sort <$> listDirectory dir -- | Executes a generic SQL migration for the provided script 'name' with content 'contents'.@@ -215,7 +215,7 @@ executeValidation con opts cmd = doStepTransaction opts con $ case cmd of MigrationInitialization ->- existsTable con (BS8.unpack $ optTableName opts) >>= \r -> pure $ if r+ existsTable con (BS8.unpack $ optTableName opts) <&> \r -> if r then MigrationSuccess else MigrationError ("No such table: " <> BS8.unpack (optTableName opts)) MigrationDirectory path ->@@ -340,11 +340,11 @@ | Quiet deriving (Show, Eq) --- | 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+-- | Determines how transactions are handled.+-- It 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 = NoNewTransaction -- ^ No new transaction will be started. Up to the caller to decide if the run is in a transaction or not | TransactionPerRun -- ^ Call 'withTransaction' once for the entire 'MigrationCommand'