DB: Add LocalTicket table
This is a step preparing for the Create flow for tickets. Each Ticket now gets a matching LocalTicket that points to it. But otherwise the LocalTicket isn't in use yet.
This commit is contained in:
parent
1a5654f8ae
commit
deeac7e760
8 changed files with 88 additions and 5 deletions
|
@ -362,6 +362,15 @@ Ticket
|
|||
UniqueTicketFollowers followers
|
||||
UniqueTicketAccept accept
|
||||
|
||||
LocalTicket
|
||||
ticket TicketId
|
||||
discuss DiscussionId
|
||||
followers FollowerSetId
|
||||
|
||||
UniqueLocalTicket ticket
|
||||
UniqueLocalTicketDiscussion discuss
|
||||
UniqueLocalTicketFollowers followers
|
||||
|
||||
TicketAuthorLocal
|
||||
ticket TicketId
|
||||
author PersonId
|
||||
|
|
8
migrations/2020_02_05_local_ticket.model
Normal file
8
migrations/2020_02_05_local_ticket.model
Normal file
|
@ -0,0 +1,8 @@
|
|||
LocalTicket
|
||||
ticket TicketId
|
||||
discuss DiscussionId
|
||||
followers FollowerSetId
|
||||
|
||||
UniqueLocalTicket ticket
|
||||
UniqueLocalTicketDiscussion discuss
|
||||
UniqueLocalTicketFollowers followers
|
37
migrations/2020_02_05_mig.model
Normal file
37
migrations/2020_02_05_mig.model
Normal file
|
@ -0,0 +1,37 @@
|
|||
Discussion
|
||||
|
||||
FollowerSet
|
||||
|
||||
Project
|
||||
|
||||
Person
|
||||
|
||||
OutboxItem
|
||||
|
||||
Ticket
|
||||
project ProjectId
|
||||
number Int Maybe
|
||||
created UTCTime
|
||||
title Text -- HTML
|
||||
source Text -- Pandoc Markdown
|
||||
description Text -- HTML
|
||||
assignee PersonId Maybe
|
||||
status Text
|
||||
closed UTCTime
|
||||
closer PersonId Maybe
|
||||
discuss DiscussionId
|
||||
followers FollowerSetId
|
||||
accept OutboxItemId
|
||||
|
||||
UniqueTicketDiscussion discuss
|
||||
UniqueTicketFollowers followers
|
||||
UniqueTicketAccept accept
|
||||
|
||||
LocalTicket
|
||||
ticket TicketId
|
||||
discuss DiscussionId
|
||||
followers FollowerSetId
|
||||
|
||||
UniqueLocalTicket ticket
|
||||
UniqueLocalTicketDiscussion discuss
|
||||
UniqueLocalTicketFollowers followers
|
|
@ -862,6 +862,11 @@ offerTicketC shrUser summary audience offer@(Offer ticket uTarget) = runExceptT
|
|||
, ticketFollowers = fsid
|
||||
, ticketAccept = obiidAccept
|
||||
}
|
||||
insert_ LocalTicket
|
||||
{ localTicketTicket = tid
|
||||
, localTicketDiscuss = did
|
||||
, localTicketFollowers = fsid
|
||||
}
|
||||
insert_ TicketAuthorLocal
|
||||
{ ticketAuthorLocalTicket = tid
|
||||
, ticketAuthorLocalAuthor = pidAuthor
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{- This file is part of Vervis.
|
||||
-
|
||||
- Written in 2019 by fr33domlover <fr33domlover@riseup.net>.
|
||||
- Written in 2019, 2020 by fr33domlover <fr33domlover@riseup.net>.
|
||||
-
|
||||
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||
-
|
||||
|
@ -122,7 +122,7 @@ parseLocalRecipient r =
|
|||
-- the code that fetches the actual recipients from the DB.
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
data LocalTicketRecipientDirect = LocalTicketTeam | LocalTicketFollowers
|
||||
data LocalTicketRecipientDirect = LocalTicketTeam | LocalTicketFollowerz
|
||||
deriving (Eq, Ord)
|
||||
|
||||
data LocalProjectRecipientDirect
|
||||
|
@ -188,7 +188,7 @@ groupedRecipientFromCollection
|
|||
groupedRecipientFromCollection
|
||||
(LocalPersonCollectionTicketFollowers shr prj num) =
|
||||
LocalSharerRelated shr $ LocalProjectRelated prj $
|
||||
LocalTicketRelated num LocalTicketFollowers
|
||||
LocalTicketRelated num LocalTicketFollowerz
|
||||
groupedRecipientFromCollection
|
||||
(LocalPersonCollectionRepoTeam shr rp) =
|
||||
LocalSharerRelated shr $ LocalRepoRelated rp $
|
||||
|
@ -301,7 +301,7 @@ groupLocalRecipients
|
|||
initial = LocalTicketDirectSet False False
|
||||
f s LocalTicketTeam =
|
||||
s { localRecipTicketTeam = True }
|
||||
f s LocalTicketFollowers =
|
||||
f s LocalTicketFollowerz =
|
||||
s { localRecipTicketFollowers = True }
|
||||
lrr2set = LocalRepoRelatedSet . foldl' f initial . NE.map unwrap
|
||||
where
|
||||
|
|
|
@ -277,6 +277,11 @@ projectOfferTicketF
|
|||
, ticketFollowers = fsid
|
||||
, ticketAccept = obiidAccept
|
||||
}
|
||||
insert_ LocalTicket
|
||||
{ localTicketTicket = tid
|
||||
, localTicketDiscuss = did
|
||||
, localTicketFollowers = fsid
|
||||
}
|
||||
insert_ TicketAuthorRemote
|
||||
{ ticketAuthorRemoteTicket = tid
|
||||
, ticketAuthorRemoteAuthor = raidAuthor
|
||||
|
|
|
@ -1233,6 +1233,17 @@ changes hLocal ctx =
|
|||
, removeUnique "Ticket" "UniqueTicket"
|
||||
-- 187
|
||||
, setFieldMaybe "Ticket" "number"
|
||||
-- 188
|
||||
, addEntities model_2020_02_05
|
||||
-- 189
|
||||
, unchecked $ lift $ do
|
||||
ts <- selectList ([] :: [Filter Ticket189]) []
|
||||
let makeLT (Entity tid t) = LocalTicket189
|
||||
{ localTicket189Ticket = tid
|
||||
, localTicket189Discuss = ticket189Discuss t
|
||||
, localTicket189Followers = ticket189Followers t
|
||||
}
|
||||
insertMany_ $ map makeLT ts
|
||||
]
|
||||
|
||||
migrateDB
|
||||
|
|
|
@ -139,6 +139,10 @@ module Vervis.Migration.Model
|
|||
, RemoteCollection159Generic (..)
|
||||
, RemoteCollection159
|
||||
, model_2020_01_05
|
||||
, model_2020_02_05
|
||||
, Ticket189
|
||||
, Ticket189Generic (..)
|
||||
, LocalTicket189Generic (..)
|
||||
)
|
||||
where
|
||||
|
||||
|
@ -146,7 +150,6 @@ import Data.ByteString (ByteString)
|
|||
import Data.Text (Text)
|
||||
import Data.Time (UTCTime)
|
||||
import Database.Persist.Class (EntityField, Unique)
|
||||
--import Database.Persist.JSON (PersistJSONValue)
|
||||
import Database.Persist.Schema.Types (Entity)
|
||||
import Database.Persist.Schema.SQL ()
|
||||
import Database.Persist.Sql (SqlBackend)
|
||||
|
@ -281,3 +284,8 @@ makeEntitiesMigration "159"
|
|||
|
||||
model_2020_01_05 :: [Entity SqlBackend]
|
||||
model_2020_01_05 = $(schema "2020_01_05")
|
||||
|
||||
model_2020_02_05 :: [Entity SqlBackend]
|
||||
model_2020_02_05 = $(schema "2020_02_05_local_ticket")
|
||||
|
||||
makeEntitiesMigration "189" $(modelFile "migrations/2020_02_05_mig.model")
|
||||
|
|
Loading…
Reference in a new issue