Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions postgresql-simple-migration.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,29 @@ Library
default-extensions: OverloadedStrings, CPP, LambdaCase
default-language: Haskell2010
build-depends: base >= 4.6 && < 5.0,
base64-bytestring >= 1.0 && < 1.1,
bytestring >= 0.10 && < 0.11,
base64-bytestring >= 1.0 && < 1.3,
bytestring >= 0.10 && < 0.12,
cryptohash >= 0.11 && < 0.12,
directory >= 1.2 && < 1.4,
postgresql-simple >= 0.4 && < 0.7,
time >= 1.4 && < 1.10
postgresql-simple >= 0.4 && < 0.8,
time >= 1.4 && < 1.13

Executable migrate
main-is: Main.hs
other-modules: Database.PostgreSQL.Simple.Migration
Database.PostgreSQL.Simple.Util
hs-source-dirs: src
ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns
default-extensions: OverloadedStrings, CPP, LambdaCase
default-language: Haskell2010
build-depends: base >= 4.6 && < 5.0,
base64-bytestring >= 1.0 && < 1.1,
bytestring >= 0.10 && < 0.11,
base64-bytestring >= 1.0 && < 1.3,
bytestring >= 0.10 && < 0.12,
cryptohash >= 0.11 && < 0.12,
directory >= 1.2 && < 1.4,
postgresql-simple >= 0.4 && < 0.7,
time >= 1.4 && < 1.10,
text >= 1.2 && < 1.3
postgresql-simple >= 0.4 && < 0.8,
time >= 1.4 && < 1.13,
text >= 1.2 && < 2.1

test-suite tests
main-is: Main.hs
Expand All @@ -69,7 +71,7 @@ test-suite tests
default-language: Haskell2010
type: exitcode-stdio-1.0
build-depends: base >= 4.6 && < 5.0,
bytestring >= 0.10 && < 0.11,
postgresql-simple >= 0.4 && < 0.7,
bytestring >= 0.10 && < 0.12,
postgresql-simple >= 0.4 && < 0.8,
hspec >= 2.2 && < 2.8,
postgresql-simple-migration
16 changes: 7 additions & 9 deletions src/Database/PostgreSQL/Simple/Migration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ import Control.Monad (void, when)
import qualified Crypto.Hash.MD5 as MD5 (hash)
import qualified Data.ByteString as BS (ByteString, readFile)
import qualified Data.ByteString.Base64 as B64 (encode)
import Data.Foldable (Foldable)
import Data.List (isPrefixOf, sort)
import Data.Traversable (Traversable)
#if __GLASGOW_HASKELL__ < 710
import Data.Monoid (Monoid (..))
#endif
Expand Down Expand Up @@ -263,17 +261,17 @@ data MigrationCommand
-- ^ Performs a series of 'MigrationCommand's in sequence.
deriving (Show, Eq, Read, Ord)

#if __GLASGOW_HASKELL__ >= 804
instance Semigroup MigrationCommand where
(<>) = mappend
#endif
(MigrationCommands xs) <> (MigrationCommands ys) = MigrationCommands (xs ++ ys)
(MigrationCommands xs) <> y = MigrationCommands (xs ++ [y])
x <> (MigrationCommands ys) = MigrationCommands (x : ys)
x <> y = MigrationCommands [x, y]

instance Monoid MigrationCommand where
mempty = MigrationCommands []
mappend (MigrationCommands xs) (MigrationCommands ys) = MigrationCommands (xs ++ ys)
mappend (MigrationCommands xs) y = MigrationCommands (xs ++ [y])
mappend x (MigrationCommands ys) = MigrationCommands (x : ys)
mappend x y = MigrationCommands [x, y]
#if !(MIN_VERSION_base(4,11,0))
mappend = (<>)
#endif

-- | A sum-type denoting the result of a single migration.
data CheckScriptResult
Expand Down