DB: Remove foreign key from TicketAuthorLocal to Ticket, not needed anymore
Since TicketAuthorLocal now points to LocalTicket, which in turn points to Ticket.
This commit is contained in:
parent
fd704e231f
commit
813869755a
6 changed files with 21 additions and 19 deletions
|
@ -368,13 +368,11 @@ LocalTicket
|
|||
UniqueLocalTicketFollowers followers
|
||||
|
||||
TicketAuthorLocal
|
||||
ticket TicketId
|
||||
ticketNew LocalTicketId
|
||||
ticket LocalTicketId
|
||||
author PersonId
|
||||
offer OutboxItemId
|
||||
|
||||
UniqueTicketAuthorLocal ticket
|
||||
UniqueTicketAuthorLocalNew ticketNew
|
||||
UniqueTicketAuthorLocalOffer offer
|
||||
|
||||
TicketAuthorRemote
|
||||
|
|
|
@ -868,8 +868,7 @@ offerTicketC shrUser summary audience offer@(Offer ticket uTarget) = runExceptT
|
|||
, localTicketFollowers = fsid
|
||||
}
|
||||
insert_ TicketAuthorLocal
|
||||
{ ticketAuthorLocalTicket = tid
|
||||
, ticketAuthorLocalTicketNew = ltid
|
||||
{ ticketAuthorLocalTicket = ltid
|
||||
, ticketAuthorLocalAuthor = pidAuthor
|
||||
, ticketAuthorLocalOffer = obiid
|
||||
}
|
||||
|
|
|
@ -695,19 +695,13 @@ postTicketsR shr prj = do
|
|||
obiid <- ExceptT $ offerTicketC shrAuthor summary audience offer
|
||||
ExceptT $ runDB $ do
|
||||
mtal <- getValBy $ UniqueTicketAuthorLocalOffer obiid
|
||||
return $
|
||||
case mtal of
|
||||
Nothing ->
|
||||
return $
|
||||
Left
|
||||
"Offer processed successfully but no ticket \
|
||||
\created"
|
||||
Just tal -> do
|
||||
let tid = ticketAuthorLocalTicket tal
|
||||
mltid <- getKeyBy $ UniqueLocalTicket tid
|
||||
return $
|
||||
case mltid of
|
||||
Nothing -> Left "Weird, no LocalTicket created"
|
||||
Just ltid -> Right ltid
|
||||
Just tal -> Right $ ticketAuthorLocalTicket tal
|
||||
case eltid of
|
||||
Left e -> do
|
||||
setMessage $ toHtml e
|
||||
|
|
|
@ -257,7 +257,7 @@ getTicketR shar proj ltkhid = do
|
|||
unless (ticketProject ticket == jid) notFound
|
||||
author <-
|
||||
requireEitherAlt
|
||||
(do mtal <- getValBy $ UniqueTicketAuthorLocal tid
|
||||
(do mtal <- getValBy $ UniqueTicketAuthorLocal ltid
|
||||
for mtal $ \ tal -> do
|
||||
p <- getJust $ ticketAuthorLocalAuthor tal
|
||||
getJust $ personIdent p
|
||||
|
@ -942,7 +942,7 @@ getTicketDeps forward shr prj ltkhid = do
|
|||
E.on $ E.just (t E.^. TicketId) E.==. tar E.?. TicketAuthorRemoteTicket
|
||||
E.on $ p E.?. PersonIdent E.==. s E.?. SharerId
|
||||
E.on $ tal E.?. TicketAuthorLocalAuthor E.==. p E.?. PersonId
|
||||
E.on $ E.just (t E.^. TicketId) E.==. tal E.?. TicketAuthorLocalTicket
|
||||
E.on $ E.just (lt E.^. LocalTicketId) E.==. tal E.?. TicketAuthorLocalTicket
|
||||
E.on $ t E.^. TicketId E.==. lt E.^. LocalTicketTicket
|
||||
E.on $ td E.^. to' E.==. t E.^. TicketId
|
||||
E.where_ $ td E.^. from' E.==. E.val tid
|
||||
|
|
|
@ -1314,6 +1314,17 @@ changes hLocal ctx =
|
|||
-- 195
|
||||
, addUnique "TicketAuthorLocal" $
|
||||
Unique "UniqueTicketAuthorLocalNew" ["ticketNew"]
|
||||
-- 196
|
||||
, removeUnique "TicketAuthorLocal" "UniqueTicketAuthorLocal"
|
||||
-- 197
|
||||
, removeField "TicketAuthorLocal" "ticket"
|
||||
-- 198
|
||||
, renameUnique
|
||||
"TicketAuthorLocal"
|
||||
"UniqueTicketAuthorLocalNew"
|
||||
"UniqueTicketAuthorLocal"
|
||||
-- 199
|
||||
, renameField "TicketAuthorLocal" "ticketNew" "ticket"
|
||||
]
|
||||
|
||||
migrateDB
|
||||
|
|
|
@ -67,7 +67,7 @@ getTicketSummaries mfilt morder offlim jid = do
|
|||
on $ just (t ^. TicketId) ==. tar ?. TicketAuthorRemoteTicket
|
||||
on $ p ?. PersonIdent ==. s ?. SharerId
|
||||
on $ tal ?. TicketAuthorLocalAuthor ==. p ?. PersonId
|
||||
on $ just (t ^. TicketId) ==. tal ?. TicketAuthorLocalTicket
|
||||
on $ just (lt ^. LocalTicketId) ==. tal ?. TicketAuthorLocalTicket
|
||||
on $ t ^. TicketId ==. lt ^. LocalTicketTicket
|
||||
where_ $ t ^. TicketProject ==. val jid
|
||||
groupBy
|
||||
|
|
Loading…
Reference in a new issue