From a65979f5af8ffa4b6b8dbb108167c9c11d1cb0d5 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Sun, 16 Jun 2019 21:34:06 +0000 Subject: [PATCH] Give Project an Outbox in the DB --- config/models | 2 ++ migrations/2019_06_16.model | 19 +++++++++++++++++++ src/Vervis/Form/Project.hs | 1 + src/Vervis/Handler/Project.hs | 2 ++ src/Vervis/Migration.hs | 14 ++++++++++++++ src/Vervis/Migration/Model.hs | 6 ++++++ 6 files changed, 44 insertions(+) create mode 100644 migrations/2019_06_16.model diff --git a/config/models b/config/models index 282f6b5..ef05986 100644 --- a/config/models +++ b/config/models @@ -218,10 +218,12 @@ Project collabUser RoleId Maybe collabAnon RoleId Maybe inbox InboxId + outbox OutboxId followers FollowerSetId UniqueProject ident sharer UniqueProjectInbox inbox + UniqueProjectOutbox outbox UniqueProjectFollowers followers Repo diff --git a/migrations/2019_06_16.model b/migrations/2019_06_16.model new file mode 100644 index 0000000..f53659e --- /dev/null +++ b/migrations/2019_06_16.model @@ -0,0 +1,19 @@ +Outbox + +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 Int64 + outbox OutboxId + followers Int64 + + UniqueProject ident sharer + UniqueProjectInbox inbox + UniqueProjectFollowers followers diff --git a/src/Vervis/Form/Project.hs b/src/Vervis/Form/Project.hs index 190a68d..38f1aec 100644 --- a/src/Vervis/Form/Project.hs +++ b/src/Vervis/Form/Project.hs @@ -123,6 +123,7 @@ editProjectAForm sid (Entity jid project) = Project <*> aopt selectRole "User role" (Just $ projectCollabUser project) <*> aopt selectRole "Guest role" (Just $ projectCollabAnon project) <*> pure (projectInbox project) + <*> pure (projectOutbox project) <*> pure (projectFollowers project) where selectWiki = diff --git a/src/Vervis/Handler/Project.hs b/src/Vervis/Handler/Project.hs index e5eadde..87aa7a9 100644 --- a/src/Vervis/Handler/Project.hs +++ b/src/Vervis/Handler/Project.hs @@ -87,6 +87,7 @@ postProjectsR shr = do pid <- requireAuthId runDB $ do ibid <- insert Inbox + obid <- insert Outbox fsid <- insert FollowerSet let project = Project { projectIdent = npIdent np @@ -99,6 +100,7 @@ postProjectsR shr = do , projectCollabAnon = Nothing , projectCollabUser = Nothing , projectInbox = ibid + , projectOutbox = obid , projectFollowers = fsid } jid <- insert project diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index c38ae97..0e4a090 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -821,6 +821,20 @@ changes hLocal ctx = "Outbox" -- 120 , removeField "OutboxItem" "person" + -- 121 + , addFieldRefRequired' + "Project" + Outbox20190616 + (Just $ do + jids <- selectKeysList ([] :: [Filter Project20190616]) [] + for_ jids $ \ jid -> do + obid <- insert Outbox20190616 + update jid [Project20190616Outbox =. obid] + ) + "outbox" + "Outbox" + -- 122 + , addUnique "Project" $ Unique "UniqueProjectOutbox" ["outbox"] ] migrateDB diff --git a/src/Vervis/Migration/Model.hs b/src/Vervis/Migration/Model.hs index 266fa76..6c2cf3e 100644 --- a/src/Vervis/Migration/Model.hs +++ b/src/Vervis/Migration/Model.hs @@ -96,6 +96,9 @@ module Vervis.Migration.Model , Outbox20190615Generic (..) , OutboxItem20190615Generic (..) , OutboxItem20190615 + , Project20190616Generic (..) + , Project20190616 + , Outbox20190616Generic (..) ) where @@ -207,3 +210,6 @@ makeEntitiesMigration "20190612" makeEntitiesMigration "20190615" $(modelFile "migrations/2019_06_15.model") + +makeEntitiesMigration "20190616" + $(modelFile "migrations/2019_06_16.model")