packages feed

drifter-postgresql 0.1.0 → 0.2.0

raw patch · 4 files changed

+22/−16 lines, 4 filesdep +transformersdep ~eitherPVP ok

version bump matches the API change (PVP)

Dependencies added: transformers

Dependency ranges changed: either

API changes (from Hackage documentation)

Files

changelog.md view
@@ -1,6 +1,11 @@+0.2.0+* Switch from EitherT to ExceptT.+ 0.1.0 * Support non-linear migration plans. This changes some types, hence a breaking version change.+ 0.0.2 * Loosen bounds+ 0.0.1 * Initial release
drifter-postgresql.cabal view
@@ -1,5 +1,5 @@ name:                drifter-postgresql-version:             0.1.0+version:             0.2.0 synopsis:            PostgreSQL support for the drifter schema migration tool description:         Support for postgresql-simple Query migrations as well as                      arbitrary Haskell IO functions. Be sure to check the@@ -32,6 +32,7 @@                      , time                      , either                      , mtl+                     , transformers   hs-source-dirs:      src   default-language:    Haskell2010 
src/Drifter/PostgreSQL.hs view
@@ -16,13 +16,13 @@     ) where  --------------------------------------------------------------------------------import           Control.Applicative+import           Control.Applicative                  as A import           Control.Exception import           Control.Monad import           Control.Monad.Trans-import           Control.Monad.Trans.Either-import           Data.Set (Set)-import qualified Data.Set as Set+import           Control.Monad.Trans.Except+import           Data.Set                             (Set)+import qualified Data.Set                             as Set import           Data.Time import           Database.PostgreSQL.Simple import           Database.PostgreSQL.Simple.FromField@@ -49,7 +49,7 @@  instance Drifter PGMigration where   migrateSingle (DBConnection migrationConn) change = do-    runEitherT $ migrateChange migrationConn change+    runExceptT $ migrateChange migrationConn change   -------------------------------------------------------------------------------@@ -117,7 +117,7 @@   --------------------------------------------------------------------------------migrateChange :: PGMigrationConnection -> Change PGMigration -> EitherT String IO ()+migrateChange :: PGMigrationConnection -> Change PGMigration -> ExceptT String IO () migrateChange (PGMigrationConnection hist c) ch@Change{..} = do   if Set.member changeName hist     then lift $ putStrLn $ "Skipping: " ++ show (changeNameText changeName)@@ -128,18 +128,18 @@   --------------------------------------------------------------------------------runMethod :: Connection -> Method PGMigration -> EitherT String IO ()+runMethod :: Connection -> Method PGMigration -> ExceptT String IO () runMethod c (MigrationQuery q) =-  void $ EitherT $ (Right <$> execute_ c q) `catches` errorHandlers+  void $ ExceptT $ (Right <$> execute_ c q) `catches` errorHandlers runMethod c (MigrationCode f) =-  EitherT $ f c `catches` errorHandlers+  ExceptT $ f c `catches` errorHandlers     --------------------------------------------------------------------------------logChange :: Connection -> Change PGMigration -> EitherT String IO ()+logChange :: Connection -> Change PGMigration -> ExceptT String IO () logChange c Change{..} = do     now <- lift getCurrentTime-    void $ EitherT $ (Right <$> go now) `catches` errorHandlers+    void $ ExceptT $ (Right <$> go now) `catches` errorHandlers   where     go now = execute c insertLogQ (changeNameText changeName, changeDescription, now) @@ -189,5 +189,5 @@ -- | Get just the names of all changes from schema_migrations for migrations -- that have previously run. getChangeNameHistory :: Connection -> IO [ChangeName]-getChangeNameHistory conn = fmap (\(Only name) -> ChangeName name)-                        <$> query_ conn changeNameHistoryQ+getChangeNameHistory conn = fmap (\(Only nm) -> ChangeName nm)+                        A.<$> query_ conn changeNameHistoryQ
test/Main.hs view
@@ -6,7 +6,7 @@   --------------------------------------------------------------------------------import           Control.Applicative+import           Control.Applicative              as A import           Control.Monad import           Data.IORef import           Data.Text                        (Text)@@ -65,7 +65,7 @@ c2 :: IORef Int -> Change PGMigration c2 ref = Change (ChangeName "c2") (Just "c2 migration") [changeName c1] meth   where-    meth = MigrationCode (\_ -> Right <$> modifyIORef' ref succ)+    meth = MigrationCode (\_ -> Right A.<$> modifyIORef' ref succ)   -------------------------------------------------------------------------------