From 3cb04cd9e68fe8d1d95af1075a7d8d26eea21a92 Mon Sep 17 00:00:00 2001 From: Vitalii Guzeev Date: Tue, 11 Sep 2018 17:14:26 +0300 Subject: [PATCH] Fix build against latest haskell-platform (ghc-8.4.3, cabal-2.2.0.0 with library 2.2.0.0) --- dbmigrations.cabal | 3 +-- src/Database/Schema/Migrations/Backend/HDBC.hs | 4 ++-- src/Database/Schema/Migrations/Filesystem.hs | 6 +++--- src/Database/Schema/Migrations/Test/BackendTest.hs | 4 ++-- src/Moo/CommandHandlers.hs | 10 +++++----- src/Moo/CommandUtils.hs | 1 - src/Moo/Core.hs | 1 - test/{TestDriver.hs => Main.hs} | 0 8 files changed, 13 insertions(+), 16 deletions(-) rename test/{TestDriver.hs => Main.hs} (100%) diff --git a/dbmigrations.cabal b/dbmigrations.cabal index 11fda54..3e91d95 100644 --- a/dbmigrations.cabal +++ b/dbmigrations.cabal @@ -139,7 +139,6 @@ test-suite dbmigrations-tests FilesystemTest MigrationsTest StoreTest - TestDriver InMemoryStore LinearMigrationsTest ConfigurationTest @@ -151,7 +150,7 @@ test-suite dbmigrations-tests ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields Hs-Source-Dirs: src,test - Main-is: TestDriver.hs + Main-is: Main.hs Executable moo default-language: Haskell2010 diff --git a/src/Database/Schema/Migrations/Backend/HDBC.hs b/src/Database/Schema/Migrations/Backend/HDBC.hs index 458905b..a7a2589 100644 --- a/src/Database/Schema/Migrations/Backend/HDBC.hs +++ b/src/Database/Schema/Migrations/Backend/HDBC.hs @@ -50,7 +50,7 @@ hdbcBackend conn = , applyMigration = \m -> do runRaw conn (mApply m) - run conn ("INSERT INTO " ++ migrationTableName ++ + _ <- run conn ("INSERT INTO " ++ migrationTableName ++ " (migration_id) VALUES (?)") [toSql $ mId m] return () @@ -59,7 +59,7 @@ hdbcBackend conn = Nothing -> return () Just query -> runRaw conn query -- Remove migration from installed_migrations in either case. - run conn ("DELETE FROM " ++ migrationTableName ++ + _ <- run conn ("DELETE FROM " ++ migrationTableName ++ " WHERE migration_id = ?") [toSql $ mId m] return () diff --git a/src/Database/Schema/Migrations/Filesystem.hs b/src/Database/Schema/Migrations/Filesystem.hs index 52388cb..e33120c 100644 --- a/src/Database/Schema/Migrations/Filesystem.hs +++ b/src/Database/Schema/Migrations/Filesystem.hs @@ -9,7 +9,7 @@ module Database.Schema.Migrations.Filesystem ) where -import Prelude hiding ( catch ) +import Prelude import System.Directory ( getDirectoryContents, doesFileExist ) import System.FilePath ( (), takeExtension, dropExtension, takeBaseName ) @@ -101,14 +101,14 @@ migrationFromPath path = do (Right <$> process name) `catch` (\(FilesystemStoreError s) -> return $ Left $ "Could not parse migration " ++ path ++ ":" ++ s) where - readMigrationFile path = do + readMigrationFile = do ymlExists <- doesFileExist (addNewMigrationExtension path) if ymlExists then parseYamlFile (addNewMigrationExtension path) `catch` (\(e::IOException) -> throwFS $ show e) else parseYamlFile (addLegacyMigrationExtension path) `catch` (\(e::IOException) -> throwFS $ show e) process name = do - yaml <- readMigrationFile path + yaml <- readMigrationFile -- Convert yaml structure into basic key/value map let fields = getFields yaml diff --git a/src/Database/Schema/Migrations/Test/BackendTest.hs b/src/Database/Schema/Migrations/Test/BackendTest.hs index e302db6..29d492f 100644 --- a/src/Database/Schema/Migrations/Test/BackendTest.hs +++ b/src/Database/Schema/Migrations/Test/BackendTest.hs @@ -102,7 +102,7 @@ applyMigrationFailure conn = do m2 = (newMigration "third") { mApply = "INVALID SQL" } -- Apply the migrations, ignore exceptions - ignoreSqlExceptions conn $ withTransaction conn $ \conn' -> do + _ <- ignoreSqlExceptions conn $ withTransaction conn $ \conn' -> do let backend' = makeBackend conn' applyMigration backend' m1 applyMigration backend' m2 @@ -129,7 +129,7 @@ revertMigrationFailure conn = do -- Revert the migrations, ignore exceptions; the revert will fail, -- but withTransaction will roll back. - ignoreSqlExceptions conn $ withTransaction conn $ \conn' -> do + _ <- ignoreSqlExceptions conn $ withTransaction conn $ \conn' -> do let backend' = makeBackend conn' revertMigration backend' m2 revertMigration backend' m1 diff --git a/src/Moo/CommandHandlers.hs b/src/Moo/CommandHandlers.hs index 392eccb..6ab7dc8 100644 --- a/src/Moo/CommandHandlers.hs +++ b/src/Moo/CommandHandlers.hs @@ -102,8 +102,8 @@ reinstallCommand storeData = do ensureBootstrappedBackend backend >> commitBackend backend m <- lookupMigration storeData migrationId - revert m storeData backend - apply m storeData backend True + _ <- revert m storeData backend + _ <- apply m storeData backend True case isTesting of False -> do @@ -130,7 +130,7 @@ applyCommand storeData = do withBackend $ \backend -> do ensureBootstrappedBackend backend >> commitBackend backend m <- lookupMigration storeData migrationId - apply m storeData backend True + _ <- apply m storeData backend True case isTesting of False -> do commitBackend backend @@ -148,7 +148,7 @@ revertCommand storeData = do withBackend $ \backend -> do ensureBootstrappedBackend backend >> commitBackend backend m <- lookupMigration storeData migrationId - revert m storeData backend + _ <- revert m storeData backend case isTesting of False -> do @@ -170,7 +170,7 @@ testCommand storeData = do -- If the migration is already installed, remove it as part of -- the test when (not $ migrationId `elem` migrationNames) $ - do revert m storeData backend + do _ <- revert m storeData backend return () applied <- apply m storeData backend True forM_ (reverse applied) $ \migration -> do diff --git a/src/Moo/CommandUtils.hs b/src/Moo/CommandUtils.hs index 9ef7ea6..937d535 100644 --- a/src/Moo/CommandUtils.hs +++ b/src/Moo/CommandUtils.hs @@ -9,7 +9,6 @@ module Moo.CommandUtils , getCurrentTimestamp ) where -import Control.Applicative import Control.Exception ( finally ) import Control.Monad ( when, forM_, unless ) import Control.Monad.Reader ( asks ) diff --git a/src/Moo/Core.hs b/src/Moo/Core.hs index a07280d..3a7d391 100644 --- a/src/Moo/Core.hs +++ b/src/Moo/Core.hs @@ -13,7 +13,6 @@ module Moo.Core , envStoreName , loadConfiguration) where -import Control.Applicative import Control.Monad.Reader (ReaderT) import qualified Data.Configurator as C import Data.Configurator.Types (Config, Configured) diff --git a/test/TestDriver.hs b/test/Main.hs similarity index 100% rename from test/TestDriver.hs rename to test/Main.hs