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
|
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
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue