From d79dca6be9a00c5dc1671e4779418f2fdc54aa02 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 19 Sep 2019 17:38:23 +0200 Subject: [PATCH] =?UTF-8?q?fix(migration):=20drop=20more=20tables=20in=20w?= =?UTF-8?q?.a.=20for=20inconsistent=2021=E2=86=9222?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Model/Migration.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Model/Migration.hs b/src/Model/Migration.hs index 8cc786739..dd04ba1d7 100644 --- a/src/Model/Migration.hs +++ b/src/Model/Migration.hs @@ -530,6 +530,12 @@ customMigrations = Map.fromListWith (>>) | oldVersion -> -- Major changes happend to the structure of exams without appropriate -- migration, try to remedy that here + tableDropEmpty "exam_part_corrector" + tableDropEmpty "exam_corrector" + tableDropEmpty "exam_result" + tableDropEmpty "exam_registration" + tableDropEmpty "exam_occurrence" + tableDropEmpty "exam_part" tableDropEmpty "exam" | otherwise -> [executeQQ| @@ -570,7 +576,7 @@ tableIsEmpty table = do return $ unSingle rows == (0 :: Int64) tableDropEmpty :: MonadIO m => Text -> ReaderT SqlBackend m () -tableDropEmpty table = do +tableDropEmpty table = whenM (tableExists table) $ do isEmpty <- tableIsEmpty table if | isEmpty -> rawExecute [st|DROP TABLE "#{table}" CASCADE|] []