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 (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
, addFieldRefRequired'
"Ticket"
(toBackendKey fsidTemp)
"followers"
"FollowerSet"
)
(lift $ do
FollowerSet2019
(Just $ do
tids <- selectKeysList ([] :: [Filter Ticket2019]) []
for_ tids $ \ tid -> do
fsid <- insert FollowerSet2019
update tid [Ticket2019Followers =. fsid]
delete fsidTemp
)
"followers"
"FollowerSet"
-- 52
, addUnique "Ticket" $ Unique "UniqueTicketFollowers" ["followers"]
-- 53

View file

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