DB: Add and populate TicketUnderProject table

A row in this table will be required for local-project-local-author tickets
hosted under the project, and non-existence of a row will be required for such
tickets hosted by the author. So I'll need to CAREFULLY update all the ticket
route handler code and all the ticket related AP code. The latter includes C2S
and S2S for tickets, ticket deps, ticket discussion... everything that is under
tickets.
This commit is contained in:
fr33domlover 2020-02-08 11:49:30 +00:00
parent 7612b4e01e
commit 5e9dd3555d
5 changed files with 63 additions and 0 deletions

View file

@ -388,6 +388,12 @@ TicketAuthorRemote
UniqueTicketAuthorRemote ticket
UniqueTicketAuthorRemoteOpen open
TicketUnderProject
project TicketProjectLocalId
author TicketAuthorLocalId
UniqueTicketUnderProject project author
TicketDependency
parent TicketId
child TicketId

View file

@ -0,0 +1,5 @@
TicketUnderProject
project TicketProjectLocalId
author TicketAuthorLocalId
UniqueTicketUnderProject project author

View file

@ -0,0 +1,32 @@
Ticket
LocalTicket
ticket TicketId
discuss Int64
followers Int64
UniqueLocalTicket ticket
UniqueLocalTicketDiscussion discuss
UniqueLocalTicketFollowers followers
TicketProjectLocal
ticket TicketId
project Int64
accept Int64
UniqueTicketProjectLocal ticket
UniqueTicketProjectLocalAccept accept
TicketAuthorLocal
ticket LocalTicketId
author Int64
open Int64
UniqueTicketAuthorLocal ticket
UniqueTicketAuthorLocalOpen open
TicketUnderProject
project TicketProjectLocalId
author TicketAuthorLocalId
UniqueTicketUnderProject project author

View file

@ -26,6 +26,7 @@ import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Maybe
import Control.Monad.Trans.Reader (ReaderT, runReaderT)
import Data.Aeson
import Data.Bifunctor
import Data.ByteString (ByteString)
import Data.Default.Class
import Data.Default.Instances.ByteString ()
@ -1452,6 +1453,17 @@ changes hLocal ctx =
, removeField "RemoteDiscussion" "ident"
-- 221
, renameField "RemoteDiscussion" "identNew" "ident"
-- 222
, addEntities model_2020_02_09
-- 223
, unchecked $ lift $ do
ids <- E.select $ E.from $
\ (tal `E.InnerJoin` lt `E.InnerJoin` t `E.InnerJoin` tpl) -> do
E.on $ t E.^. Ticket223Id E.==. tpl E.^. TicketProjectLocal223Ticket
E.on $ lt E.^. LocalTicket223Ticket E.==. t E.^. Ticket223Id
E.on $ tal E.^. TicketAuthorLocal223Ticket E.==. lt E.^. LocalTicket223Id
return (tpl E.^. TicketProjectLocal223Id, tal E.^. TicketAuthorLocal223Id)
insertMany_ $ map (uncurry TicketUnderProject223 . bimap E.unValue E.unValue) ids
]
migrateDB

View file

@ -174,6 +174,8 @@ module Vervis.Migration.Model
, RemoteObject215Generic (..)
, RemoteDiscussion215
, RemoteDiscussion215Generic (..)
, model_2020_02_09
, TicketUnderProject223Generic (..)
)
where
@ -335,3 +337,9 @@ makeEntitiesMigration "205"
makeEntitiesMigration "215"
$(modelFile "migrations/2020_02_09_rd_point_to_ro.model")
model_2020_02_09 :: [Entity SqlBackend]
model_2020_02_09 = $(schema "2020_02_09_tup")
makeEntitiesMigration "223"
$(modelFile "migrations/2020_02_09_tup_mig.model")