DB: Remove unnecessary fkey from TicketAuthorRemote to Ticket

Since it points to TicketProjectLocal which in turn points to Ticket.
This commit is contained in:
fr33domlover 2020-02-07 23:05:42 +00:00
parent 5b57039447
commit 6e2445a31f
5 changed files with 20 additions and 10 deletions

View file

@ -381,13 +381,11 @@ TicketAuthorLocal
UniqueTicketAuthorLocalOffer offer UniqueTicketAuthorLocalOffer offer
TicketAuthorRemote TicketAuthorRemote
ticket TicketId ticket TicketProjectLocalId
ticketNew TicketProjectLocalId
author RemoteActorId author RemoteActorId
offer RemoteActivityId offer RemoteActivityId
UniqueTicketAuthorRemote ticket UniqueTicketAuthorRemote ticket
UniqueTicketAuthorRemoteNew ticketNew
UniqueTicketAuthorRemoteOffer offer UniqueTicketAuthorRemoteOffer offer
TicketDependency TicketDependency

View file

@ -284,8 +284,7 @@ projectOfferTicketF
, ticketProjectLocalAccept = obiidAccept , ticketProjectLocalAccept = obiidAccept
} }
insert_ TicketAuthorRemote insert_ TicketAuthorRemote
{ ticketAuthorRemoteTicket = tid { ticketAuthorRemoteTicket = tplid
, ticketAuthorRemoteTicketNew = tplid
, ticketAuthorRemoteAuthor = raidAuthor , ticketAuthorRemoteAuthor = raidAuthor
, ticketAuthorRemoteOffer = ractid , ticketAuthorRemoteOffer = ractid
} }

View file

@ -260,7 +260,7 @@ getTicketR shar proj ltkhid = do
ltid <- decodeKeyHashid404 ltkhid ltid <- decodeKeyHashid404 ltkhid
lticket <- get404 ltid lticket <- get404 ltid
let tid = localTicketTicket lticket let tid = localTicketTicket lticket
tpl <- getValBy404 $ UniqueTicketProjectLocal tid Entity tplid tpl <- getBy404 $ UniqueTicketProjectLocal tid
unless (ticketProjectLocalProject tpl == jid) notFound unless (ticketProjectLocalProject tpl == jid) notFound
author <- author <-
requireEitherAlt requireEitherAlt
@ -269,7 +269,7 @@ getTicketR shar proj ltkhid = do
p <- getJust $ ticketAuthorLocalAuthor tal p <- getJust $ ticketAuthorLocalAuthor tal
getJust $ personIdent p getJust $ personIdent p
) )
(do mtar <- getValBy $ UniqueTicketAuthorRemote tid (do mtar <- getValBy $ UniqueTicketAuthorRemote tplid
for mtar $ \ tar -> do for mtar $ \ tar -> do
ra <- getJust $ ticketAuthorRemoteAuthor tar ra <- getJust $ ticketAuthorRemoteAuthor tar
ro <- getJust $ remoteActorIdent ra ro <- getJust $ remoteActorIdent ra
@ -954,16 +954,18 @@ getTicketDeps forward shr prj ltkhid = do
\ ( td \ ( td
`E.InnerJoin` t `E.InnerJoin` t
`E.InnerJoin` lt `E.InnerJoin` lt
`E.InnerJoin` tpl
`E.LeftOuterJoin` (tal `E.InnerJoin` p `E.InnerJoin` s) `E.LeftOuterJoin` (tal `E.InnerJoin` p `E.InnerJoin` s)
`E.LeftOuterJoin` (tar `E.InnerJoin` ra `E.InnerJoin` ro `E.InnerJoin` i) `E.LeftOuterJoin` (tar `E.InnerJoin` ra `E.InnerJoin` ro `E.InnerJoin` i)
) -> do ) -> do
E.on $ ro E.?. RemoteObjectInstance E.==. i E.?. InstanceId E.on $ ro E.?. RemoteObjectInstance E.==. i E.?. InstanceId
E.on $ ra E.?. RemoteActorIdent E.==. ro E.?. RemoteObjectId E.on $ ra E.?. RemoteActorIdent E.==. ro E.?. RemoteObjectId
E.on $ tar E.?. TicketAuthorRemoteAuthor E.==. ra E.?. RemoteActorId E.on $ tar E.?. TicketAuthorRemoteAuthor E.==. ra E.?. RemoteActorId
E.on $ E.just (t E.^. TicketId) E.==. tar E.?. TicketAuthorRemoteTicket E.on $ E.just (tpl E.^. TicketProjectLocalId) E.==. tar E.?. TicketAuthorRemoteTicket
E.on $ p E.?. PersonIdent E.==. s E.?. SharerId E.on $ p E.?. PersonIdent E.==. s E.?. SharerId
E.on $ tal E.?. TicketAuthorLocalAuthor E.==. p E.?. PersonId E.on $ tal E.?. TicketAuthorLocalAuthor E.==. p E.?. PersonId
E.on $ E.just (lt E.^. LocalTicketId) E.==. tal E.?. TicketAuthorLocalTicket E.on $ E.just (lt E.^. LocalTicketId) E.==. tal E.?. TicketAuthorLocalTicket
E.on $ t E.^. TicketId E.==. tpl E.^. TicketProjectLocalTicket
E.on $ t E.^. TicketId E.==. lt E.^. LocalTicketTicket E.on $ t E.^. TicketId E.==. lt E.^. LocalTicketTicket
E.on $ td E.^. to' E.==. t E.^. TicketId E.on $ td E.^. to' E.==. t E.^. TicketId
E.where_ $ td E.^. from' E.==. E.val tid E.where_ $ td E.^. from' E.==. E.val tid

View file

@ -1396,6 +1396,17 @@ changes hLocal ctx =
-- 206 -- 206
, addUnique "TicketAuthorRemote" $ , addUnique "TicketAuthorRemote" $
Unique "UniqueTicketAuthorRemoteNew" ["ticketNew"] Unique "UniqueTicketAuthorRemoteNew" ["ticketNew"]
-- 207
, removeUnique "TicketAuthorRemote" "UniqueTicketAuthorRemote"
-- 208
, removeField "TicketAuthorRemote" "ticket"
-- 209
, renameUnique
"TicketAuthorRemote"
"UniqueTicketAuthorRemoteNew"
"UniqueTicketAuthorRemote"
-- 210
, renameField "TicketAuthorRemote" "ticketNew" "ticket"
] ]
migrateDB migrateDB

View file

@ -65,7 +65,7 @@ getTicketSummaries mfilt morder offlim jid = do
on $ ro ?. RemoteObjectInstance ==. i ?. InstanceId on $ ro ?. RemoteObjectInstance ==. i ?. InstanceId
on $ ra ?. RemoteActorIdent ==. ro ?. RemoteObjectId on $ ra ?. RemoteActorIdent ==. ro ?. RemoteObjectId
on $ tar ?. TicketAuthorRemoteAuthor ==. ra ?. RemoteActorId on $ tar ?. TicketAuthorRemoteAuthor ==. ra ?. RemoteActorId
on $ just (t ^. TicketId) ==. tar ?. TicketAuthorRemoteTicket on $ just (tpl ^. TicketProjectLocalId) ==. tar ?. TicketAuthorRemoteTicket
on $ p ?. PersonIdent ==. s ?. SharerId on $ p ?. PersonIdent ==. s ?. SharerId
on $ tal ?. TicketAuthorLocalAuthor ==. p ?. PersonId on $ tal ?. TicketAuthorLocalAuthor ==. p ?. PersonId
on $ just (lt ^. LocalTicketId) ==. tal ?. TicketAuthorLocalTicket on $ just (lt ^. LocalTicketId) ==. tal ?. TicketAuthorLocalTicket