diff --git a/config/models b/config/models index c87ee40..d5ee5c6 100644 --- a/config/models +++ b/config/models @@ -213,8 +213,10 @@ Project wiki RepoId Maybe collabUser RoleId Maybe collabAnon RoleId Maybe + inbox InboxId UniqueProject ident sharer + UniqueProjectInbox inbox Repo ident RpIdent diff --git a/migrations/2019_06_09.model b/migrations/2019_06_09.model new file mode 100644 index 0000000..aa75531 --- /dev/null +++ b/migrations/2019_06_09.model @@ -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 diff --git a/src/Vervis/Form/Project.hs b/src/Vervis/Form/Project.hs index 49ca6b2..16c1ef8 100644 --- a/src/Vervis/Form/Project.hs +++ b/src/Vervis/Form/Project.hs @@ -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 $ diff --git a/src/Vervis/Handler/Project.hs b/src/Vervis/Handler/Project.hs index 19c55a7..3d7415e 100644 --- a/src/Vervis/Handler/Project.hs +++ b/src/Vervis/Handler/Project.hs @@ -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 diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index 50ef528..ac28280 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -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 diff --git a/src/Vervis/Migration/Model.hs b/src/Vervis/Migration/Model.hs index 1d3e535..f7a4174 100644 --- a/src/Vervis/Migration/Model.hs +++ b/src/Vervis/Migration/Model.hs @@ -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")