diff --git a/config/models b/config/models index db79a76..6bcabf1 100644 --- a/config/models +++ b/config/models @@ -388,6 +388,12 @@ TicketAuthorRemote UniqueTicketAuthorRemote ticket UniqueTicketAuthorRemoteOpen open +TicketUnderProject + project TicketProjectLocalId + author TicketAuthorLocalId + + UniqueTicketUnderProject project author + TicketDependency parent TicketId child TicketId diff --git a/migrations/2020_02_09_tup.model b/migrations/2020_02_09_tup.model new file mode 100644 index 0000000..390050d --- /dev/null +++ b/migrations/2020_02_09_tup.model @@ -0,0 +1,5 @@ +TicketUnderProject + project TicketProjectLocalId + author TicketAuthorLocalId + + UniqueTicketUnderProject project author diff --git a/migrations/2020_02_09_tup_mig.model b/migrations/2020_02_09_tup_mig.model new file mode 100644 index 0000000..f8059a9 --- /dev/null +++ b/migrations/2020_02_09_tup_mig.model @@ -0,0 +1,32 @@ +Ticket + +LocalTicket + ticket TicketId + discuss Int64 + followers Int64 + + UniqueLocalTicket ticket + UniqueLocalTicketDiscussion discuss + UniqueLocalTicketFollowers followers + +TicketProjectLocal + ticket TicketId + project Int64 + accept Int64 + + UniqueTicketProjectLocal ticket + UniqueTicketProjectLocalAccept accept + +TicketAuthorLocal + ticket LocalTicketId + author Int64 + open Int64 + + UniqueTicketAuthorLocal ticket + UniqueTicketAuthorLocalOpen open + +TicketUnderProject + project TicketProjectLocalId + author TicketAuthorLocalId + + UniqueTicketUnderProject project author diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index e3fb4cf..003d88d 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -26,6 +26,7 @@ import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Maybe import Control.Monad.Trans.Reader (ReaderT, runReaderT) import Data.Aeson +import Data.Bifunctor import Data.ByteString (ByteString) import Data.Default.Class import Data.Default.Instances.ByteString () @@ -1452,6 +1453,17 @@ changes hLocal ctx = , removeField "RemoteDiscussion" "ident" -- 221 , renameField "RemoteDiscussion" "identNew" "ident" + -- 222 + , addEntities model_2020_02_09 + -- 223 + , unchecked $ lift $ do + ids <- E.select $ E.from $ + \ (tal `E.InnerJoin` lt `E.InnerJoin` t `E.InnerJoin` tpl) -> do + E.on $ t E.^. Ticket223Id E.==. tpl E.^. TicketProjectLocal223Ticket + E.on $ lt E.^. LocalTicket223Ticket E.==. t E.^. Ticket223Id + E.on $ tal E.^. TicketAuthorLocal223Ticket E.==. lt E.^. LocalTicket223Id + return (tpl E.^. TicketProjectLocal223Id, tal E.^. TicketAuthorLocal223Id) + insertMany_ $ map (uncurry TicketUnderProject223 . bimap E.unValue E.unValue) ids ] migrateDB diff --git a/src/Vervis/Migration/Model.hs b/src/Vervis/Migration/Model.hs index 016f518..c3d4c94 100644 --- a/src/Vervis/Migration/Model.hs +++ b/src/Vervis/Migration/Model.hs @@ -174,6 +174,8 @@ module Vervis.Migration.Model , RemoteObject215Generic (..) , RemoteDiscussion215 , RemoteDiscussion215Generic (..) + , model_2020_02_09 + , TicketUnderProject223Generic (..) ) where @@ -335,3 +337,9 @@ makeEntitiesMigration "205" makeEntitiesMigration "215" $(modelFile "migrations/2020_02_09_rd_point_to_ro.model") + +model_2020_02_09 :: [Entity SqlBackend] +model_2020_02_09 = $(schema "2020_02_09_tup") + +makeEntitiesMigration "223" + $(modelFile "migrations/2020_02_09_tup_mig.model")