DB: Add a Komponent record, to gather local repos/decks/looms/etc.

This commit is contained in:
Pere Lev 2024-04-29 14:38:37 +03:00
parent 1d08e43175
commit aeb1a83c93
No known key found for this signature in database
GPG key ID: 5252C5C863E5E57D
9 changed files with 203 additions and 19 deletions

View file

@ -0,0 +1,4 @@
Komponent
resource ResourceId
UniqueKomponent resource

View file

@ -0,0 +1,69 @@
Workflow
OutboxItem
Outbox
Inbox
FollowerSet
Actor
name Text
desc Text
createdAt UTCTime
inbox InboxId
outbox OutboxId
followers FollowerSetId
justCreatedBy ActorId Maybe
errbox InboxId
UniqueActorInbox inbox
UniqueActorOutbox outbox
UniqueActorFollowers followers
Resource
actor ActorId
UniqueResource actor
Komponent
resource ResourceId
UniqueKomponent resource
Deck
actor ActorId
resource ResourceId
komponent KomponentId
workflow WorkflowId
nextTicket Int
wiki RepoId Maybe
create OutboxItemId
UniqueDeckActor actor
UniqueDeckCreate create
Loom
nextTicket Int
actor ActorId
resource ResourceId
komponent KomponentId
repo RepoId
create OutboxItemId
UniqueLoomActor actor
UniqueLoomRepo repo
UniqueLoomCreate create
Repo
vcs VersionControlSystem
project DeckId Maybe
mainBranch Text
actor ActorId
resource ResourceId
komponent KomponentId
create OutboxItemId
loom LoomId Maybe
UniqueRepoActor actor
UniqueRepoCreate create

View file

@ -1132,10 +1132,12 @@ createPatchTrackerC (Entity pidUser personUser) senderActor maybeCap localRecips
actor@(Entity actorID _) <- actor@(Entity actorID _) <-
insertActor now name (fromMaybe "" msummary) (Just $ personActor personUser) insertActor now name (fromMaybe "" msummary) (Just $ personActor personUser)
resourceID <- insert $ Resource actorID resourceID <- insert $ Resource actorID
komponentID <- insert $ Komponent resourceID
loomID <- insert Loom loomID <- insert Loom
{ loomNextTicket = 1 { loomNextTicket = 1
, loomActor = actorID , loomActor = actorID
, loomResource = resourceID , loomResource = resourceID
, loomKomponent = komponentID
, loomRepo = repoID , loomRepo = repoID
, loomCreate = obiidCreate , loomCreate = obiidCreate
} }
@ -1369,12 +1371,14 @@ createRepositoryC (Entity pidUser personUser) senderActor maybeCap localRecips r
actor@(Entity actorID _) <- actor@(Entity actorID _) <-
insertActor now name (fromMaybe "" msummary) (Just $ personActor personUser) insertActor now name (fromMaybe "" msummary) (Just $ personActor personUser)
resourceID <- insert $ Resource actorID resourceID <- insert $ Resource actorID
komponentID <- insert $ Komponent resourceID
repoID <- insert Repo repoID <- insert Repo
{ repoVcs = vcs { repoVcs = vcs
, repoProject = Nothing , repoProject = Nothing
, repoMainBranch = "main" , repoMainBranch = "main"
, repoActor = actorID , repoActor = actorID
, repoResource = resourceID , repoResource = resourceID
, repoKomponent = komponentID
, repoCreate = createID , repoCreate = createID
, repoLoom = Nothing , repoLoom = Nothing
} }

View file

@ -79,13 +79,14 @@ import Vervis.Web.Collab
-- Meaning: An actor is adding some object to some target -- Meaning: An actor is adding some object to some target
-- Behavior: -- Behavior:
-- * If the object is me:
-- * Verify that the object is me -- * Verify that the object is me
-- * Verify the target is some project's components collection URI -- * Verify the target is some project's components collection URI
-- * Verify the Add is authorized -- * Verify the Add is authorized
-- * For all the Stem records I have for this project: -- * For all the Stem records I have for this project:
-- * Verify I'm not yet a member of the project -- * Verify I'm not yet a member of the project
-- * Verify I haven't already Accepted an Add to this project -- * Verify I haven't already Accepted an our-Add to this project
-- * Verify I haven't already seen an Invite-and-Project-accept for -- * Verify I haven't already seen an them-Invite-and-Project-accept for
-- this project -- this project
-- * Insert the Add to my inbox -- * Insert the Add to my inbox
-- * Create a Stem record in DB -- * Create a Stem record in DB

View file

@ -462,9 +462,11 @@ clientCreateDeck now personMeID (ClientMsg maybeCap localRecips remoteRecips fwd
insertDeck now name msummary obiidCreate wid actorMeID = do insertDeck now name msummary obiidCreate wid actorMeID = do
Entity aid a <- insertActor now name (fromMaybe "" msummary) (Just actorMeID) Entity aid a <- insertActor now name (fromMaybe "" msummary) (Just actorMeID)
rid <- insert $ Resource aid rid <- insert $ Resource aid
kid <- insert $ Komponent rid
did <- insert Deck did <- insert Deck
{ deckActor = aid { deckActor = aid
, deckResource = rid , deckResource = rid
, deckKomponent = kid
, deckWorkflow = wid , deckWorkflow = wid
, deckNextTicket = 1 , deckNextTicket = 1
, deckWiki = Nothing , deckWiki = Nothing

View file

@ -3618,6 +3618,95 @@ changes hLocal ctx =
) )
"errbox" "errbox"
"Inbox" "Inbox"
-- 626
, addEntities model_626_komponent
-- 627
, addFieldRefRequired''
"Repo"
(do inboxID <- insert Inbox627
errboxID <- insert Inbox627
outboxID <- insert Outbox627
followerSetID <- insert FollowerSet627
actorID <- insert $ Actor627 "" "" defaultTime inboxID outboxID followerSetID Nothing errboxID
resourceID <- insert $ Resource627 actorID
insertEntity $ Komponent627 resourceID
)
(Just $ \ (Entity tempKomponentID (Komponent627 tempResourceID)) -> do
l <- selectList [] []
for_ l $ \ (Entity k v) -> do
kID <- insert $ Komponent627 $ repo627Resource v
update k [Repo627Komponent =. kID]
Resource627 tempActorID <- getJust tempResourceID
Actor627 _ _ _ inboxID outboxID followerSetID _ errboxID <- getJust tempActorID
delete tempKomponentID
delete tempResourceID
delete tempActorID
delete inboxID
delete errboxID
delete outboxID
delete followerSetID
)
"komponent"
"Komponent"
-- 628
, addFieldRefRequired''
"Deck"
(do inboxID <- insert Inbox627
errboxID <- insert Inbox627
outboxID <- insert Outbox627
followerSetID <- insert FollowerSet627
actorID <- insert $ Actor627 "" "" defaultTime inboxID outboxID followerSetID Nothing errboxID
resourceID <- insert $ Resource627 actorID
insertEntity $ Komponent627 resourceID
)
(Just $ \ (Entity tempKomponentID (Komponent627 tempResourceID)) -> do
l <- selectList [] []
for_ l $ \ (Entity k v) -> do
kID <- insert $ Komponent627 $ deck627Resource v
update k [Deck627Komponent =. kID]
Resource627 tempActorID <- getJust tempResourceID
Actor627 _ _ _ inboxID outboxID followerSetID _ errboxID <- getJust tempActorID
delete tempKomponentID
delete tempResourceID
delete tempActorID
delete inboxID
delete errboxID
delete outboxID
delete followerSetID
)
"komponent"
"Komponent"
-- 629
, addFieldRefRequired''
"Loom"
(do inboxID <- insert Inbox627
errboxID <- insert Inbox627
outboxID <- insert Outbox627
followerSetID <- insert FollowerSet627
actorID <- insert $ Actor627 "" "" defaultTime inboxID outboxID followerSetID Nothing errboxID
resourceID <- insert $ Resource627 actorID
insertEntity $ Komponent627 resourceID
)
(Just $ \ (Entity tempKomponentID (Komponent627 tempResourceID)) -> do
l <- selectList [] []
for_ l $ \ (Entity k v) -> do
kID <- insert $ Komponent627 $ loom627Resource v
update k [Loom627Komponent =. kID]
Resource627 tempActorID <- getJust tempResourceID
Actor627 _ _ _ inboxID outboxID followerSetID _ errboxID <- getJust tempActorID
delete tempKomponentID
delete tempResourceID
delete tempActorID
delete inboxID
delete errboxID
delete outboxID
delete followerSetID
)
"komponent"
"Komponent"
] ]
migrateDB migrateDB

View file

@ -75,6 +75,7 @@ module Vervis.Migration.Entities
, model_592_permit_extend , model_592_permit_extend
, model_601_permit_extend_resource , model_601_permit_extend_resource
, model_603_resource , model_603_resource
, model_626_komponent
) )
where where
@ -293,3 +294,6 @@ model_601_permit_extend_resource =
model_603_resource :: [Entity SqlBackend] model_603_resource :: [Entity SqlBackend]
model_603_resource = $(schema "603_2024-04-20_resource") model_603_resource = $(schema "603_2024-04-20_resource")
model_626_komponent :: [Entity SqlBackend]
model_626_komponent = $(schema "626_2024-04-29_komponent")

View file

@ -69,3 +69,6 @@ makeEntitiesMigration "611"
makeEntitiesMigration "625" makeEntitiesMigration "625"
$(modelFile "migrations/625_2024-04-27_errbox.model") $(modelFile "migrations/625_2024-04-27_errbox.model")
makeEntitiesMigration "627"
$(modelFile "migrations/627_2024-04-29_komponent_mig.model")

View file

@ -156,6 +156,11 @@ Resource
UniqueResource actor UniqueResource actor
Komponent
resource ResourceId
UniqueKomponent resource
-- ========================================================================= -- -- ========================================================================= --
-- Delivery -- Delivery
-- ========================================================================= -- -- ========================================================================= --
@ -307,6 +312,7 @@ Project
Deck Deck
actor ActorId actor ActorId
resource ResourceId resource ResourceId
komponent KomponentId
workflow WorkflowId workflow WorkflowId
nextTicket Int nextTicket Int
wiki RepoId Maybe wiki RepoId Maybe
@ -319,6 +325,7 @@ Loom
nextTicket Int nextTicket Int
actor ActorId actor ActorId
resource ResourceId resource ResourceId
komponent KomponentId
repo RepoId repo RepoId
create OutboxItemId create OutboxItemId
@ -332,6 +339,7 @@ Repo
mainBranch Text mainBranch Text
actor ActorId actor ActorId
resource ResourceId resource ResourceId
komponent KomponentId
create OutboxItemId create OutboxItemId
loom LoomId Maybe loom LoomId Maybe