Give each project an inbox in DB

This commit is contained in:
fr33domlover 2019-06-09 16:21:23 +00:00
parent f70aa42060
commit f4e324e587
6 changed files with 42 additions and 1 deletions

View file

@ -213,8 +213,10 @@ Project
wiki RepoId Maybe
collabUser RoleId Maybe
collabAnon RoleId Maybe
inbox InboxId
UniqueProject ident sharer
UniqueProjectInbox inbox
Repo
ident RpIdent

View file

@ -0,0 +1,15 @@
Inbox
Project
ident PrjIdent
sharer Int64
name Text Maybe
desc Text Maybe
workflow Int64
nextTicket Int
wiki Int64 Maybe
collabUser Int64 Maybe
collabAnon Int64 Maybe
inbox InboxId
UniqueProject ident sharer

View file

@ -115,6 +115,7 @@ editProjectAForm sid (Entity jid project) = Project
<*> aopt selectWiki "Wiki" (Just $ projectWiki project)
<*> aopt selectRole "User role" (Just $ projectCollabUser project)
<*> aopt selectRole "Guest role" (Just $ projectCollabAnon project)
<*> pure (projectInbox project)
where
selectWiki =
selectField $

View file

@ -77,6 +77,7 @@ postProjectsR shr = do
FormSuccess np -> do
pid <- requireAuthId
runDB $ do
ibid <- insert Inbox
let project = Project
{ projectIdent = npIdent np
, projectSharer = sid
@ -87,6 +88,7 @@ postProjectsR shr = do
, projectWiki = Nothing
, projectCollabAnon = Nothing
, projectCollabUser = Nothing
, projectInbox = ibid
}
jid <- insert project
let collab = ProjectCollab

View file

@ -595,9 +595,25 @@ changes hLocal ctx =
Unique "UniqueInboxItemRemote" ["inbox", "activity"]
-- 105
, addUnique "Person" $ Unique "UniquePersonInbox" ["inbox"]
-- 106
, addFieldRefRequired'
"Project"
Inbox20190609
(Just $ do
jids <- selectKeysList ([] :: [Filter Project20190609]) []
for_ jids $ \ jid -> do
ibid <- insert Inbox20190609
update jid [Project20190609Inbox =. ibid]
)
"inbox"
"Inbox"
-- 107
, addUnique "Project" $ Unique "UniqueProjectInbox" ["inbox"]
]
migrateDB :: MonadIO m => Text -> HashidsContext -> ReaderT SqlBackend m (Either Text (Int, Int))
migrateDB
:: MonadIO m
=> Text -> HashidsContext -> ReaderT SqlBackend m (Either Text (Int, Int))
migrateDB hLocal ctx =
let f cs = fmap (, length cs) <$> runMigrations schemaBackend 1 cs
in f $ changes hLocal ctx

View file

@ -68,6 +68,8 @@ module Vervis.Migration.Model
, InboxItemLocal20190607
, InboxItemRemote20190607Generic (..)
, InboxItemRemote20190607
, Project20190609
, Inbox20190609Generic (..)
)
where
@ -166,3 +168,6 @@ makeEntitiesMigration "20190606"
makeEntitiesMigration "20190607"
$(modelFile "migrations/2019_06_07.model")
makeEntitiesMigration "20190609"
$(modelFile "migrations/2019_06_09.model")