From 7621c0280ac6f46e833be0dbdf96b3c495b036f6 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Thu, 11 Apr 2019 16:43:46 +0000 Subject: [PATCH] Rewrite ticketFollowers migration without insertKey, it causes problems --- src/Vervis/Migration.hs | 31 +++++++++++++------------------ src/Vervis/Migration/Model.hs | 1 - 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index 853d85d..b41356b 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -62,8 +62,8 @@ defaultTime = UTCTime (ModifiedJulianDay 0) 0 withPrepare :: Monad m => Mig m -> Apply m -> Mig m withPrepare (validate, apply) prepare = (validate, prepare >> apply) -withPrePost :: Monad m => Apply m -> Mig m -> Apply m -> Mig m -withPrePost pre (validate, apply) post = (validate, pre >> apply >> post) +--withPrePost :: Monad m => Apply m -> Mig m -> Apply m -> Mig m +--withPrePost pre (validate, apply) post = (validate, pre >> apply >> post) changes :: MonadIO m => [Mig m] changes = @@ -212,22 +212,17 @@ changes = -- 50 , addEntities model_2019_03_30 -- 51 - , let fsidTemp = fromBackendKey defaultBackendKey :: Key FollowerSet2019 - in withPrePost - (lift $ insertKey fsidTemp FollowerSet2019) - (addFieldRefRequired - "Ticket" - (toBackendKey fsidTemp) - "followers" - "FollowerSet" - ) - (lift $ do - tids <- selectKeysList ([] :: [Filter Ticket2019]) [] - for_ tids $ \ tid -> do - fsid <- insert FollowerSet2019 - update tid [Ticket2019Followers =. fsid] - delete fsidTemp - ) + , addFieldRefRequired' + "Ticket" + FollowerSet2019 + (Just $ do + tids <- selectKeysList ([] :: [Filter Ticket2019]) [] + for_ tids $ \ tid -> do + fsid <- insert FollowerSet2019 + update tid [Ticket2019Followers =. fsid] + ) + "followers" + "FollowerSet" -- 52 , addUnique "Ticket" $ Unique "UniqueTicketFollowers" ["followers"] -- 53 diff --git a/src/Vervis/Migration/Model.hs b/src/Vervis/Migration/Model.hs index 6af2f74..72983b5 100644 --- a/src/Vervis/Migration/Model.hs +++ b/src/Vervis/Migration/Model.hs @@ -34,7 +34,6 @@ module Vervis.Migration.Model , model_2019_03_19 , model_2019_03_30 , FollowerSet2019Generic (..) - , FollowerSet2019 , Ticket2019 , model_2019_04_11 )