Rewrite ticketFollowers migration without insertKey, it causes problems

This commit is contained in:
fr33domlover 2019-04-11 16:43:46 +00:00
parent 9a306e762c
commit 7621c0280a
2 changed files with 13 additions and 19 deletions

View file

@ -62,8 +62,8 @@ defaultTime = UTCTime (ModifiedJulianDay 0) 0
withPrepare :: Monad m => Mig m -> Apply m -> Mig m withPrepare :: Monad m => Mig m -> Apply m -> Mig m
withPrepare (validate, apply) prepare = (validate, prepare >> apply) withPrepare (validate, apply) prepare = (validate, prepare >> apply)
withPrePost :: Monad m => Apply m -> Mig m -> Apply m -> Mig m --withPrePost :: Monad m => Apply m -> Mig m -> Apply m -> Mig m
withPrePost pre (validate, apply) post = (validate, pre >> apply >> post) --withPrePost pre (validate, apply) post = (validate, pre >> apply >> post)
changes :: MonadIO m => [Mig m] changes :: MonadIO m => [Mig m]
changes = changes =
@ -212,22 +212,17 @@ changes =
-- 50 -- 50
, addEntities model_2019_03_30 , addEntities model_2019_03_30
-- 51 -- 51
, let fsidTemp = fromBackendKey defaultBackendKey :: Key FollowerSet2019 , addFieldRefRequired'
in withPrePost "Ticket"
(lift $ insertKey fsidTemp FollowerSet2019) FollowerSet2019
(addFieldRefRequired (Just $ do
"Ticket" tids <- selectKeysList ([] :: [Filter Ticket2019]) []
(toBackendKey fsidTemp) for_ tids $ \ tid -> do
"followers" fsid <- insert FollowerSet2019
"FollowerSet" update tid [Ticket2019Followers =. fsid]
) )
(lift $ do "followers"
tids <- selectKeysList ([] :: [Filter Ticket2019]) [] "FollowerSet"
for_ tids $ \ tid -> do
fsid <- insert FollowerSet2019
update tid [Ticket2019Followers =. fsid]
delete fsidTemp
)
-- 52 -- 52
, addUnique "Ticket" $ Unique "UniqueTicketFollowers" ["followers"] , addUnique "Ticket" $ Unique "UniqueTicketFollowers" ["followers"]
-- 53 -- 53

View file

@ -34,7 +34,6 @@ module Vervis.Migration.Model
, model_2019_03_19 , model_2019_03_19
, model_2019_03_30 , model_2019_03_30
, FollowerSet2019Generic (..) , FollowerSet2019Generic (..)
, FollowerSet2019
, Ticket2019 , Ticket2019
, model_2019_04_11 , model_2019_04_11
) )