From 9d6143765eba02c53137b6ca42606b4970813579 Mon Sep 17 00:00:00 2001 From: KtorZ Date: Tue, 14 Jan 2020 10:20:09 +0100 Subject: [PATCH] flatten result after tryJust to a single 'Either' --- lib/core/src/Cardano/DB/Sqlite.hs | 4 +++- lib/core/test/unit/Cardano/Pool/DB/SqliteSpec.hs | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/core/src/Cardano/DB/Sqlite.hs b/lib/core/src/Cardano/DB/Sqlite.hs index 43545785f64..7ae08851e35 100644 --- a/lib/core/src/Cardano/DB/Sqlite.hs +++ b/lib/core/src/Cardano/DB/Sqlite.hs @@ -45,7 +45,7 @@ import Control.Concurrent.MVar import Control.Exception ( Exception, bracket_, tryJust ) import Control.Monad - ( mapM_ ) + ( join, mapM_ ) import Control.Monad.Catch ( Handler (..), MonadCatch (..), handleIf, handleJust ) import Control.Monad.Logger @@ -191,6 +191,8 @@ startSqliteBackend migrateAll trace fp = do migrations <- runQuery (runMigrationQuiet migrateAll) & tryJust (matchMigrationError @PersistException) & tryJust (matchMigrationError @SqliteException) + & fmap join + :: IO (Either MigrationError [Text]) traceWith trace $ MsgMigrations (fmap length migrations) let ctx = SqliteContext backend runQuery fp trace case migrations of diff --git a/lib/core/test/unit/Cardano/Pool/DB/SqliteSpec.hs b/lib/core/test/unit/Cardano/Pool/DB/SqliteSpec.hs index 6dbd19dc6b3..a2b20792a3f 100644 --- a/lib/core/test/unit/Cardano/Pool/DB/SqliteSpec.hs +++ b/lib/core/test/unit/Cardano/Pool/DB/SqliteSpec.hs @@ -53,9 +53,7 @@ test_migrationFromv20191216 = withDBLayer tr (Just path) $ \_ -> pure () let databaseConnMsg = filter isMsgConnStr logs - let databaseResetMsg = filter (== MsgDatabaseReset) logs - let migrationErrMsg = filter isMsgMigrationError logs length databaseConnMsg `shouldBe` 3