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:
fr33domlover 2020-02-06 03:41:16 +00:00
parent fd704e231f
commit 813869755a
6 changed files with 21 additions and 19 deletions

View file

@ -368,13 +368,11 @@ LocalTicket
UniqueLocalTicketFollowers followers UniqueLocalTicketFollowers followers
TicketAuthorLocal TicketAuthorLocal
ticket TicketId ticket LocalTicketId
ticketNew LocalTicketId
author PersonId author PersonId
offer OutboxItemId offer OutboxItemId
UniqueTicketAuthorLocal ticket UniqueTicketAuthorLocal ticket
UniqueTicketAuthorLocalNew ticketNew
UniqueTicketAuthorLocalOffer offer UniqueTicketAuthorLocalOffer offer
TicketAuthorRemote TicketAuthorRemote

View file

@ -868,8 +868,7 @@ offerTicketC shrUser summary audience offer@(Offer ticket uTarget) = runExceptT
, localTicketFollowers = fsid , localTicketFollowers = fsid
} }
insert_ TicketAuthorLocal insert_ TicketAuthorLocal
{ ticketAuthorLocalTicket = tid { ticketAuthorLocalTicket = ltid
, ticketAuthorLocalTicketNew = ltid
, ticketAuthorLocalAuthor = pidAuthor , ticketAuthorLocalAuthor = pidAuthor
, ticketAuthorLocalOffer = obiid , ticketAuthorLocalOffer = obiid
} }

View file

@ -695,19 +695,13 @@ postTicketsR shr prj = do
obiid <- ExceptT $ offerTicketC shrAuthor summary audience offer obiid <- ExceptT $ offerTicketC shrAuthor summary audience offer
ExceptT $ runDB $ do ExceptT $ runDB $ do
mtal <- getValBy $ UniqueTicketAuthorLocalOffer obiid mtal <- getValBy $ UniqueTicketAuthorLocalOffer obiid
case mtal of return $
Nothing -> case mtal of
return $ Nothing ->
Left Left
"Offer processed successfully but no ticket \ "Offer processed successfully but no ticket \
\created" \created"
Just tal -> do Just tal -> Right $ ticketAuthorLocalTicket tal
let tid = ticketAuthorLocalTicket tal
mltid <- getKeyBy $ UniqueLocalTicket tid
return $
case mltid of
Nothing -> Left "Weird, no LocalTicket created"
Just ltid -> Right ltid
case eltid of case eltid of
Left e -> do Left e -> do
setMessage $ toHtml e setMessage $ toHtml e

View file

@ -257,7 +257,7 @@ getTicketR shar proj ltkhid = do
unless (ticketProject ticket == jid) notFound unless (ticketProject ticket == jid) notFound
author <- author <-
requireEitherAlt requireEitherAlt
(do mtal <- getValBy $ UniqueTicketAuthorLocal tid (do mtal <- getValBy $ UniqueTicketAuthorLocal ltid
for mtal $ \ tal -> do for mtal $ \ tal -> do
p <- getJust $ ticketAuthorLocalAuthor tal p <- getJust $ ticketAuthorLocalAuthor tal
getJust $ personIdent p 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 $ E.just (t E.^. TicketId) 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 (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 $ 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

@ -1314,6 +1314,17 @@ changes hLocal ctx =
-- 195 -- 195
, addUnique "TicketAuthorLocal" $ , addUnique "TicketAuthorLocal" $
Unique "UniqueTicketAuthorLocalNew" ["ticketNew"] Unique "UniqueTicketAuthorLocalNew" ["ticketNew"]
-- 196
, removeUnique "TicketAuthorLocal" "UniqueTicketAuthorLocal"
-- 197
, removeField "TicketAuthorLocal" "ticket"
-- 198
, renameUnique
"TicketAuthorLocal"
"UniqueTicketAuthorLocalNew"
"UniqueTicketAuthorLocal"
-- 199
, renameField "TicketAuthorLocal" "ticketNew" "ticket"
] ]
migrateDB migrateDB

View file

@ -67,7 +67,7 @@ getTicketSummaries mfilt morder offlim jid = do
on $ just (t ^. TicketId) ==. tar ?. TicketAuthorRemoteTicket on $ just (t ^. TicketId) ==. tar ?. TicketAuthorRemoteTicket
on $ p ?. PersonIdent ==. s ?. SharerId on $ p ?. PersonIdent ==. s ?. SharerId
on $ tal ?. TicketAuthorLocalAuthor ==. p ?. PersonId on $ tal ?. TicketAuthorLocalAuthor ==. p ?. PersonId
on $ just (t ^. TicketId) ==. tal ?. TicketAuthorLocalTicket on $ just (lt ^. LocalTicketId) ==. tal ?. TicketAuthorLocalTicket
on $ t ^. TicketId ==. lt ^. LocalTicketTicket on $ t ^. TicketId ==. lt ^. LocalTicketTicket
where_ $ t ^. TicketProject ==. val jid where_ $ t ^. TicketProject ==. val jid
groupBy groupBy