DB: Point from TicketAuthorRemote to TicketProjectLocal
This commit is contained in:
parent
ea7d806233
commit
5b57039447
5 changed files with 145 additions and 1 deletions
|
@ -382,10 +382,12 @@ TicketAuthorLocal
|
|||
|
||||
TicketAuthorRemote
|
||||
ticket TicketId
|
||||
ticketNew TicketProjectLocalId
|
||||
author RemoteActorId
|
||||
offer RemoteActivityId
|
||||
|
||||
UniqueTicketAuthorRemote ticket
|
||||
UniqueTicketAuthorRemoteNew ticketNew
|
||||
UniqueTicketAuthorRemoteOffer offer
|
||||
|
||||
TicketDependency
|
||||
|
|
73
migrations/2020_02_08_tar_point_to_tpl.model
Normal file
73
migrations/2020_02_08_tar_point_to_tpl.model
Normal file
|
@ -0,0 +1,73 @@
|
|||
Sharer
|
||||
ident ShrIdent
|
||||
name Text Maybe
|
||||
created UTCTime
|
||||
|
||||
UniqueSharer ident
|
||||
|
||||
Outbox
|
||||
|
||||
OutboxItem
|
||||
outbox OutboxId
|
||||
activity PersistJSONObject
|
||||
published UTCTime
|
||||
|
||||
Inbox
|
||||
|
||||
FollowerSet
|
||||
|
||||
Project
|
||||
ident PrjIdent
|
||||
sharer SharerId
|
||||
name Text Maybe
|
||||
desc Text Maybe
|
||||
workflow WorkflowId
|
||||
nextTicket Int
|
||||
wiki Int64 Maybe
|
||||
collabUser Int64 Maybe
|
||||
collabAnon Int64 Maybe
|
||||
inbox InboxId
|
||||
outbox OutboxId
|
||||
followers FollowerSetId
|
||||
|
||||
UniqueProject ident sharer
|
||||
UniqueProjectInbox inbox
|
||||
UniqueProjectOutbox outbox
|
||||
UniqueProjectFollowers followers
|
||||
|
||||
Workflow
|
||||
sharer SharerId
|
||||
ident WflIdent
|
||||
name Text Maybe
|
||||
desc Text Maybe
|
||||
scope WorkflowScope
|
||||
|
||||
UniqueWorkflow sharer ident
|
||||
|
||||
Ticket
|
||||
number Int Maybe
|
||||
created UTCTime
|
||||
title Text -- HTML
|
||||
source Text -- Pandoc Markdown
|
||||
description Text -- HTML
|
||||
assignee Int64 Maybe
|
||||
status Text
|
||||
closed UTCTime
|
||||
closer Int64 Maybe
|
||||
|
||||
TicketProjectLocal
|
||||
ticket TicketId
|
||||
project ProjectId
|
||||
accept OutboxItemId
|
||||
|
||||
UniqueTicketProjectLocal ticket
|
||||
UniqueTicketProjectLocalAccept accept
|
||||
|
||||
TicketAuthorRemote
|
||||
ticket TicketId
|
||||
ticketNew TicketProjectLocalId
|
||||
author Int64
|
||||
offer Int64
|
||||
|
||||
UniqueTicketAuthorRemote ticket
|
||||
UniqueTicketAuthorRemoteOffer offer
|
|
@ -278,13 +278,14 @@ projectOfferTicketF
|
|||
, localTicketDiscuss = did
|
||||
, localTicketFollowers = fsid
|
||||
}
|
||||
insert_ TicketProjectLocal
|
||||
tplid <- insert TicketProjectLocal
|
||||
{ ticketProjectLocalTicket = tid
|
||||
, ticketProjectLocalProject = jid
|
||||
, ticketProjectLocalAccept = obiidAccept
|
||||
}
|
||||
insert_ TicketAuthorRemote
|
||||
{ ticketAuthorRemoteTicket = tid
|
||||
, ticketAuthorRemoteTicketNew = tplid
|
||||
, ticketAuthorRemoteAuthor = raidAuthor
|
||||
, ticketAuthorRemoteOffer = ractid
|
||||
}
|
||||
|
|
|
@ -1342,6 +1342,60 @@ changes hLocal ctx =
|
|||
, removeUnique "Ticket" "UniqueTicketAccept"
|
||||
-- 204
|
||||
, removeField "Ticket" "accept"
|
||||
-- 205
|
||||
, addFieldRefRequired''
|
||||
"TicketAuthorRemote"
|
||||
(do tid <- insert $ Ticket205 Nothing defaultTime "" "" "" Nothing "TSNew" defaultTime Nothing
|
||||
jid <- do
|
||||
let temp = "$$temp$$"
|
||||
sid <- insert $ Sharer205 (text2shr temp) Nothing defaultTime
|
||||
wid <- insert $ Workflow205 sid (text2wfl temp) Nothing Nothing WSSharer
|
||||
ibid <- insert Inbox205
|
||||
obid <- insert Outbox205
|
||||
fsid <- insert FollowerSet205
|
||||
insert $ Project205 (text2prj temp) sid Nothing Nothing wid 1 Nothing Nothing Nothing ibid obid fsid
|
||||
obiid <- do
|
||||
obid <- insert Outbox205
|
||||
let h = Authority "x.y" Nothing :: Host
|
||||
doc = Doc h emptyActivity
|
||||
insert $ OutboxItem205 obid (persistJSONObjectFromDoc doc) defaultTime
|
||||
insertEntity $ TicketProjectLocal205 tid jid obiid
|
||||
)
|
||||
(Just $ \ (Entity tplidTemp tplTemp) -> do
|
||||
tars <- selectList ([] :: [Filter TicketAuthorRemote205]) []
|
||||
for_ tars $ \ (Entity tarid tar) -> do
|
||||
tplid <- do
|
||||
mtplid <- getKeyBy $ UniqueTicketProjectLocal205 $ ticketAuthorRemote205Ticket tar
|
||||
case mtplid of
|
||||
Nothing -> error $ "No TicketProjectLocal for tarid#" ++ show tarid
|
||||
Just k -> return k
|
||||
update tarid [TicketAuthorRemote205TicketNew =. tplid]
|
||||
|
||||
delete tplidTemp
|
||||
|
||||
let tid = ticketProjectLocal205Ticket tplTemp
|
||||
_t <- getJust tid
|
||||
delete tid
|
||||
|
||||
let jid = ticketProjectLocal205Project tplTemp
|
||||
j <- getJust jid
|
||||
delete jid
|
||||
delete $ project205Workflow j
|
||||
delete $ project205Sharer j
|
||||
delete $ project205Inbox j
|
||||
delete $ project205Outbox j
|
||||
delete $ project205Followers j
|
||||
|
||||
let obiid = ticketProjectLocal205Accept tplTemp
|
||||
obi <- getJust obiid
|
||||
delete obiid
|
||||
delete $ outboxItem205Outbox obi
|
||||
)
|
||||
"ticketNew"
|
||||
"TicketProjectLocal"
|
||||
-- 206
|
||||
, addUnique "TicketAuthorRemote" $
|
||||
Unique "UniqueTicketAuthorRemoteNew" ["ticketNew"]
|
||||
]
|
||||
|
||||
migrateDB
|
||||
|
|
|
@ -159,6 +159,17 @@ module Vervis.Migration.Model
|
|||
, Ticket201
|
||||
, Ticket201Generic (..)
|
||||
, TicketProjectLocal201Generic (..)
|
||||
, Sharer205Generic (..)
|
||||
, Outbox205Generic (..)
|
||||
, OutboxItem205Generic (..)
|
||||
, Inbox205Generic (..)
|
||||
, FollowerSet205Generic (..)
|
||||
, Project205Generic (..)
|
||||
, Workflow205Generic (..)
|
||||
, Ticket205Generic (..)
|
||||
, TicketProjectLocal205Generic (..)
|
||||
, TicketAuthorRemote205
|
||||
, TicketAuthorRemote205Generic (..)
|
||||
)
|
||||
where
|
||||
|
||||
|
@ -314,3 +325,6 @@ model_2020_02_07 = $(schema "2020_02_07_tpl")
|
|||
|
||||
makeEntitiesMigration "201"
|
||||
$(modelFile "migrations/2020_02_07_tpl_mig.model")
|
||||
|
||||
makeEntitiesMigration "205"
|
||||
$(modelFile "migrations/2020_02_08_tar_point_to_tpl.model")
|
||||
|
|
Loading…
Reference in a new issue