fix(build): migration needs to check for table existens first

This commit is contained in:
Steffen Jost 2024-01-23 19:20:32 +01:00
parent de45731a9b
commit f439ea45af
2 changed files with 4 additions and 1 deletions

View File

@ -179,7 +179,7 @@ customMigrations = mapF $ \case
|]
Migration20240124UniquenessCompanyAvsNr ->
unlessM (indexExists "unique_company_avs_id") $ do -- companies with avs_id == 0 can be deleted; company users are deleted automatically by cascade
whenM (tableExists "company" `and2M` notM (indexExists "unique_company_avs_id")) $ do -- companies with avs_id == 0 can be deleted; company users are deleted automatically by cascade
[executeQQ|
DELETE FROM "company" WHERE avs_id = 0;
ALTER TABLE "company" DROP CONSTRAINT IF EXISTS "unique_company_shorthand";

View File

@ -1196,6 +1196,9 @@ ifM c x y = c >>= bool y x
ifNotM :: Monad m => m Bool -> m a -> m a -> m a
ifNotM c = flip $ ifM c
notM :: Functor f => f Bool -> f Bool
notM = fmap not
-- | Short-circuiting monadic boolean function, copied from Andreas Abel's utility function
and2M, or2M :: Monad m => m Bool -> m Bool -> m Bool
and2M ma mb = ifM ma mb (return False)