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|] []