DB: Move new entity declarations to a new module Vervis.Migration.Entities

This commit is contained in:
fr33domlover 2022-10-19 09:06:38 +00:00
parent 6407aaf897
commit eb342b47ed
4 changed files with 231 additions and 170 deletions

View file

@ -89,6 +89,7 @@ import Vervis.Model.Ident
import Vervis.Model.Ticket
import Vervis.Model.Workflow
import Vervis.Foundation (App (..), Route (..))
import Vervis.Migration.Entities
import Vervis.Migration.Model
import Vervis.Settings

View file

@ -0,0 +1,229 @@
{- This file is part of Vervis.
-
- Written in 2018, 2019, 2020, 2022 by fr33domlover <fr33domlover@riseup.net>.
-
- Copying is an act of love. Please copy, reuse and share.
-
- The author(s) have dedicated all copyright and related and neighboring
- rights to this software to the public domain worldwide. This software is
- distributed without any warranty.
-
- You should have received a copy of the CC0 Public Domain Dedication along
- with this software. If not, see
- <http://creativecommons.org/publicdomain/zero/1.0/>.
-}
module Vervis.Migration.Entities
( model_2016_08_04
, model_2016_09_01_just_workflow
, model_2016_09_01_rest
, model_2019_02_03_verifkey
, model_2019_03_19
, model_2019_03_30
, model_2019_04_11
, model_2019_04_12
, model_2019_04_22
, model_2019_05_03
, model_2019_05_17
, model_2019_06_06
, model_2019_09_25
, model_2019_11_04
, model_2020_01_05
, model_2020_02_05
, model_2020_02_07
, model_2020_02_09
, model_2020_02_22
, model_2020_04_07
, model_2020_04_09
, model_2020_05_12
, model_2020_05_16
, model_2020_05_17
, model_2020_05_25
, model_2020_05_28
, model_2020_06_01
, model_2020_06_18
, model_2020_07_23
, model_2020_07_27
, model_2020_08_10
, model_2022_06_14
, model_2022_07_17
, model_2022_07_24
, model_384_loom
, model_386_assignee
, model_399_fwder
, model_408_collab_loom
, model_425_collab_accept
, model_428_collab_topic_local
, model_451_collab_remote_accept
, model_453_collab_receive
, model_494_mr_origin
, model_497_sigkey
)
where
import Data.ByteString (ByteString)
import Data.Text (Text)
import Data.Time (UTCTime)
import Database.Persist.Class (EntityField, Unique)
import Database.Persist.EmailAddress ()
import Database.Persist.Schema.Types (Entity)
import Database.Persist.Schema.SQL ()
import Database.Persist.Schema.TH (makeEntitiesMigration)
import Database.Persist.Sql (SqlBackend)
import Text.Email.Validate (EmailAddress)
import Web.Text (HTML, PandocMarkdown)
import Crypto.ActorKey
import Development.PatchMediaType
import Development.PatchMediaType.Persist
import Vervis.FedURI
import Vervis.Migration.TH (schema)
import Vervis.Model.Group
import Vervis.Model.Ident
import Vervis.Model.Role
import Vervis.Model.TH
import Vervis.Model.Ticket
import Vervis.Model.Workflow
-- For migrations 77, 114
import Data.Int
import Database.Persist.JSON
import Network.FedURI
import Web.ActivityPub
type PersistActivity = PersistJSON (Doc Activity URIMode)
model_2016_08_04 :: [Entity SqlBackend]
model_2016_08_04 = $(schema "2016_08_04")
model_2016_09_01_just_workflow :: [Entity SqlBackend]
model_2016_09_01_just_workflow = $(schema "2016_09_01_just_workflow")
model_2016_09_01_rest :: [Entity SqlBackend]
model_2016_09_01_rest = $(schema "2016_09_01_rest")
model_2019_02_03_verifkey :: [Entity SqlBackend]
model_2019_02_03_verifkey = $(schema "2019_02_03_verifkey")
model_2019_03_19 :: [Entity SqlBackend]
model_2019_03_19 = $(schema "2019_03_19")
model_2019_03_30 :: [Entity SqlBackend]
model_2019_03_30 = $(schema "2019_03_30")
model_2019_04_11 :: [Entity SqlBackend]
model_2019_04_11 = $(schema "2019_04_11")
model_2019_04_12 :: [Entity SqlBackend]
model_2019_04_12 = $(schema "2019_04_12")
model_2019_04_22 :: [Entity SqlBackend]
model_2019_04_22 = $(schema "2019_04_22")
model_2019_05_03 :: [Entity SqlBackend]
model_2019_05_03 = $(schema "2019_05_03")
model_2019_05_17 :: [Entity SqlBackend]
model_2019_05_17 = $(schema "2019_05_17")
model_2019_06_06 :: [Entity SqlBackend]
model_2019_06_06 = $(schema "2019_06_06")
model_2019_09_25 :: [Entity SqlBackend]
model_2019_09_25 = $(schema "2019_09_25")
model_2019_11_04 :: [Entity SqlBackend]
model_2019_11_04 = $(schema "2019_11_04")
model_2020_01_05 :: [Entity SqlBackend]
model_2020_01_05 = $(schema "2020_01_05")
model_2020_02_05 :: [Entity SqlBackend]
model_2020_02_05 = $(schema "2020_02_05_local_ticket")
model_2020_02_07 :: [Entity SqlBackend]
model_2020_02_07 = $(schema "2020_02_07_tpl")
model_2020_02_09 :: [Entity SqlBackend]
model_2020_02_09 = $(schema "2020_02_09_tup")
model_2020_02_22 :: [Entity SqlBackend]
model_2020_02_22 = $(schema "2020_02_22_tpr")
model_2020_04_07 :: [Entity SqlBackend]
model_2020_04_07 = $(schema "2020_04_07_tpra")
model_2020_04_09 :: [Entity SqlBackend]
model_2020_04_09 = $(schema "2020_04_09_rt")
model_2020_05_12 :: [Entity SqlBackend]
model_2020_05_12 = $(schema "2020_05_12_fwd_sender")
model_2020_05_16 :: [Entity SqlBackend]
model_2020_05_16 = $(schema "2020_05_16_tcl")
model_2020_05_17 :: [Entity SqlBackend]
model_2020_05_17 = $(schema "2020_05_17_patch")
model_2020_05_25 :: [Entity SqlBackend]
model_2020_05_25 = $(schema "2020_05_25_fwd_sender_repo")
model_2020_05_28 :: [Entity SqlBackend]
model_2020_05_28 = $(schema "2020_05_28_tda")
model_2020_06_01 :: [Entity SqlBackend]
model_2020_06_01 = $(schema "2020_06_01_tdc")
model_2020_06_18 :: [Entity SqlBackend]
model_2020_06_18 = $(schema "2020_06_18_tdo")
model_2020_07_23 :: [Entity SqlBackend]
model_2020_07_23 = $(schema "2020_07_23_remote_collection_reboot")
model_2020_07_27 :: [Entity SqlBackend]
model_2020_07_27 = $(schema "2020_07_27_ticket_resolve")
model_2020_08_10 :: [Entity SqlBackend]
model_2020_08_10 = $(schema "2020_08_10_bundle")
model_2022_06_14 :: [Entity SqlBackend]
model_2022_06_14 = $(schema "2022_06_14_collab")
model_2022_07_17 :: [Entity SqlBackend]
model_2022_07_17 = $(schema "2022_07_17_actor")
model_2022_07_24 :: [Entity SqlBackend]
model_2022_07_24 = $(schema "2022_07_24_collab_fulfills")
model_384_loom :: [Entity SqlBackend]
model_384_loom = $(schema "384_2022-08-04_loom")
model_386_assignee :: [Entity SqlBackend]
model_386_assignee = $(schema "386_2022-08-04_assignee")
model_399_fwder :: [Entity SqlBackend]
model_399_fwder = $(schema "399_2022-08-04_fwder")
model_408_collab_loom :: [Entity SqlBackend]
model_408_collab_loom = $(schema "408_2022-08-04_collab_loom")
model_425_collab_accept :: [Entity SqlBackend]
model_425_collab_accept = $(schema "425_2022-08-21_collab_accept")
model_428_collab_topic_local :: [Entity SqlBackend]
model_428_collab_topic_local = $(schema "428_2022-08-29_collab_topic_local")
model_451_collab_remote_accept :: [Entity SqlBackend]
model_451_collab_remote_accept = $(schema "451_2022-08-30_collab_remote_accept")
model_453_collab_receive :: [Entity SqlBackend]
model_453_collab_receive = $(schema "453_2022-09-01_collab_receive")
model_494_mr_origin :: [Entity SqlBackend]
model_494_mr_origin = $(schema "494_2022-09-17_mr_origin")
model_497_sigkey :: [Entity SqlBackend]
model_497_sigkey = $(schema "497_2022-09-29_sigkey")

View file

@ -17,14 +17,10 @@ module Vervis.Migration.Model
{-
( EntityField (..)
, Unique (..)
, model_2016_08_04
, model_2016_09_01_just_workflow
, Sharer2016
, Project2016
, Workflow2016Generic (..)
, Workflow2016
, model_2016_09_01_rest
, model_2019_02_03_verifkey
, VerifKey2019Generic (..)
, VerifKey2019
, VerifKeySharedUsage2019Generic (..)
@ -33,15 +29,8 @@ module Vervis.Migration.Model
, Message2019
, LocalMessage2019Generic (..)
, LocalMessage2019
, model_2019_03_19
, model_2019_03_30
, FollowerSet2019Generic (..)
, Ticket2019
, model_2019_04_11
, model_2019_04_12
, model_2019_04_22
, model_2019_05_03
, model_2019_05_17
, Sharer201905Generic (..)
, Person201905Generic (..)
, OutboxItem201905Generic (..)
@ -58,7 +47,6 @@ module Vervis.Migration.Model
, Message201906
, Ticket201906Generic (..)
, Ticket201906
, model_2019_06_06
, Ticket20190606Generic (..)
, Ticket20190606
, TicketAuthorLocal20190606Generic (..)
@ -125,8 +113,6 @@ module Vervis.Migration.Model
, Person130
, Outbox138Generic (..)
, Repo138
, model_2019_09_25
, model_2019_11_04
, Instance152Generic (..)
, RemoteObject152Generic (..)
, RemoteActivity152Generic (..)
@ -139,8 +125,6 @@ module Vervis.Migration.Model
, UnfetchedRemoteActor159
, RemoteCollection159Generic (..)
, RemoteCollection159
, model_2020_01_05
, model_2020_02_05
, Ticket189
, Ticket189Generic (..)
, LocalTicket189Generic (..)
@ -156,7 +140,6 @@ module Vervis.Migration.Model
, TicketAuthorLocal194
, TicketAuthorLocal194Generic (..)
, Discussion194Generic (..)
, model_2020_02_07
, Ticket201
, Ticket201Generic (..)
, TicketProjectLocal201Generic (..)
@ -175,38 +158,28 @@ module Vervis.Migration.Model
, RemoteObject215Generic (..)
, RemoteDiscussion215
, RemoteDiscussion215Generic (..)
, model_2020_02_09
, TicketUnderProject223Generic (..)
, Instance227Generic (..)
, RemoteObject227Generic (..)
, RemoteMessage227
, RemoteMessage227Generic (..)
, model_2020_02_22
, model_2020_04_07
, model_2020_04_09
, RemoteTicket238
, RemoteTicket238Generic (..)
, Instance238Generic (..)
, RemoteObject238Generic (..)
, Discussion238Generic (..)
, RemoteDiscussion238Generic (..)
, model_2020_05_12
, Forwarding241
, Forwarding241Generic (..)
, ForwarderProject241Generic (..)
, model_2020_05_16
, TicketContextLocal247
, TicketContextLocal247Generic (..)
, TicketProjectLocal247Generic (..)
, model_2020_05_17
, model_2020_05_25
, model_2020_05_28
, OutboxItem255Generic (..)
, Person255Generic (..)
, TicketDependency255
, TicketDependency255Generic (..)
, TicketDependencyAuthorLocal255Generic (..)
, model_2020_06_01
, RemoteTicket260Generic (..)
, LocalTicketDependency260
, LocalTicketDependency260Generic (..)
@ -227,9 +200,6 @@ module Vervis.Migration.Model
, TicketUnderProject266Generic (..)
, TicketProjectLocal266Generic (..)
, Project266Generic (..)
, model_2020_06_18
, model_2020_07_23
, model_2020_07_27
, TicketResolve276Generic (..)
, TicketResolveLocal276Generic (..)
, Ticket276Generic (..)
@ -239,14 +209,12 @@ module Vervis.Migration.Model
, OutboxItem276Generic (..)
, TicketProjectLocal276Generic (..)
, Project276Generic (..)
, model_2020_08_10
, Ticket280Generic (..)
, Bundle280Generic (..)
, Patch280
, Patch280Generic (..)
, Repo282
, Repo282Generic (..)
, model_2022_06_14
, Collab285Generic (..)
, CollabRecipLocal285Generic (..)
, CollabRoleLocal285Generic (..)
@ -260,7 +228,6 @@ module Vervis.Migration.Model
, Repo285Generic (..)
, RepoCollab285
, RepoCollab285Generic (..)
, model_2022_07_17
, Project289
, Inbox289Generic (..)
, Outbox289Generic (..)
@ -272,7 +239,6 @@ module Vervis.Migration.Model
, Project297
, Project297Generic (..)
, Person297Generic (..)
, model_2022_07_24
, CollabTopicLocalProject300
, CollabTopicLocalProject300Generic (..)
, CollabTopicLocalRepo300
@ -321,54 +287,21 @@ import Web.ActivityPub
type PersistActivity = PersistJSON (Doc Activity URIMode)
model_2016_08_04 :: [Entity SqlBackend]
model_2016_08_04 = $(schema "2016_08_04")
model_2016_09_01_just_workflow :: [Entity SqlBackend]
model_2016_09_01_just_workflow = $(schema "2016_09_01_just_workflow")
makeEntitiesMigration "2016"
$(modelFile "migrations/2016_09_01_just_workflow_prepare.model")
model_2016_09_01_rest :: [Entity SqlBackend]
model_2016_09_01_rest = $(schema "2016_09_01_rest")
makeEntitiesMigration "2018"
$(modelFile "migrations/2019_01_28_project_collabs.model")
model_2019_02_03_verifkey :: [Entity SqlBackend]
model_2019_02_03_verifkey = $(schema "2019_02_03_verifkey")
makeEntitiesMigration "2019"
$(modelFile "migrations/2019_02_03_verifkey.model")
makeEntitiesMigration "2019"
$(modelFile "migrations/2019_03_18_message.model")
model_2019_03_19 :: [Entity SqlBackend]
model_2019_03_19 = $(schema "2019_03_19")
model_2019_03_30 :: [Entity SqlBackend]
model_2019_03_30 = $(schema "2019_03_30")
makeEntitiesMigration "2019"
$(modelFile "migrations/2019_03_30_follower_set.model")
model_2019_04_11 :: [Entity SqlBackend]
model_2019_04_11 = $(schema "2019_04_11")
model_2019_04_12 :: [Entity SqlBackend]
model_2019_04_12 = $(schema "2019_04_12")
model_2019_04_22 :: [Entity SqlBackend]
model_2019_04_22 = $(schema "2019_04_22")
model_2019_05_03 :: [Entity SqlBackend]
model_2019_05_03 = $(schema "2019_05_03")
model_2019_05_17 :: [Entity SqlBackend]
model_2019_05_17 = $(schema "2019_05_17")
makeEntitiesMigration "201905"
$(modelFile "migrations/2019_05_24.model")
@ -378,9 +311,6 @@ makeEntitiesMigration "201906"
makeEntitiesMigration "201906"
$(modelFile "migrations/2019_06_03.model")
model_2019_06_06 :: [Entity SqlBackend]
model_2019_06_06 = $(schema "2019_06_06")
makeEntitiesMigration "20190606"
$(modelFile "migrations/2019_06_06_mig.model")
@ -417,32 +347,17 @@ makeEntitiesMigration "130"
makeEntitiesMigration "138"
$(modelFile "migrations/2019_09_10.model")
model_2019_09_25 :: [Entity SqlBackend]
model_2019_09_25 = $(schema "2019_09_25")
model_2019_11_04 :: [Entity SqlBackend]
model_2019_11_04 = $(schema "2019_11_04")
makeEntitiesMigration "152"
$(modelFile "migrations/2019_11_04_remote_activity_ident.model")
makeEntitiesMigration "159"
$(modelFile "migrations/2019_11_05_remote_actor_ident.model")
model_2020_01_05 :: [Entity SqlBackend]
model_2020_01_05 = $(schema "2020_01_05")
model_2020_02_05 :: [Entity SqlBackend]
model_2020_02_05 = $(schema "2020_02_05_local_ticket")
makeEntitiesMigration "189" $(modelFile "migrations/2020_02_05_mig.model")
makeEntitiesMigration "194"
$(modelFile "migrations/2020_02_06_tal_point_to_lt.model")
model_2020_02_07 :: [Entity SqlBackend]
model_2020_02_07 = $(schema "2020_02_07_tpl")
makeEntitiesMigration "201"
$(modelFile "migrations/2020_02_07_tpl_mig.model")
@ -452,52 +367,22 @@ 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")
makeEntitiesMigration "227"
$(modelFile "migrations/2020_02_10_rm_point_to_ro.model")
model_2020_02_22 :: [Entity SqlBackend]
model_2020_02_22 = $(schema "2020_02_22_tpr")
model_2020_04_07 :: [Entity SqlBackend]
model_2020_04_07 = $(schema "2020_04_07_tpra")
model_2020_04_09 :: [Entity SqlBackend]
model_2020_04_09 = $(schema "2020_04_09_rt")
makeEntitiesMigration "238" $(modelFile "migrations/2020_04_10_rt_rd.model")
model_2020_05_12 :: [Entity SqlBackend]
model_2020_05_12 = $(schema "2020_05_12_fwd_sender")
makeEntitiesMigration "241"
$(modelFile "migrations/2020_05_12_fwd_sender_mig.model")
model_2020_05_16 :: [Entity SqlBackend]
model_2020_05_16 = $(schema "2020_05_16_tcl")
makeEntitiesMigration "247"
$(modelFile "migrations/2020_05_16_tcl_mig.model")
model_2020_05_17 :: [Entity SqlBackend]
model_2020_05_17 = $(schema "2020_05_17_patch")
model_2020_05_25 :: [Entity SqlBackend]
model_2020_05_25 = $(schema "2020_05_25_fwd_sender_repo")
model_2020_05_28 :: [Entity SqlBackend]
model_2020_05_28 = $(schema "2020_05_28_tda")
makeEntitiesMigration "255" $(modelFile "migrations/2020_05_28_tda_mig.model")
model_2020_06_01 :: [Entity SqlBackend]
model_2020_06_01 = $(schema "2020_06_01_tdc")
makeEntitiesMigration "260" $(modelFile "migrations/2020_06_01_tdc_mig.model")
makeEntitiesMigration "263" $(modelFile "migrations/2020_06_02_tdp.model")
@ -505,52 +390,27 @@ makeEntitiesMigration "263" $(modelFile "migrations/2020_06_02_tdp.model")
makeEntitiesMigration "266"
$(modelFile "migrations/2020_06_15_td_accept.model")
model_2020_06_18 :: [Entity SqlBackend]
model_2020_06_18 = $(schema "2020_06_18_tdo")
model_2020_07_23 :: [Entity SqlBackend]
model_2020_07_23 = $(schema "2020_07_23_remote_collection_reboot")
model_2020_07_27 :: [Entity SqlBackend]
model_2020_07_27 = $(schema "2020_07_27_ticket_resolve")
makeEntitiesMigration "276"
$(modelFile "migrations/2020_07_27_ticket_resolve_mig.model")
model_2020_08_10 :: [Entity SqlBackend]
model_2020_08_10 = $(schema "2020_08_10_bundle")
makeEntitiesMigration "280"
$(modelFile "migrations/2020_08_10_bundle_mig.model")
makeEntitiesMigration "282"
$(modelFile "migrations/2020_08_13_vcs.model")
model_2022_06_14 :: [Entity SqlBackend]
model_2022_06_14 = $(schema "2022_06_14_collab")
makeEntitiesMigration "285"
$(modelFile "migrations/2022_06_14_collab_mig.model")
model_2022_07_17 :: [Entity SqlBackend]
model_2022_07_17 = $(schema "2022_07_17_actor")
makeEntitiesMigration "289"
$(modelFile "migrations/2022_07_17_project_actor.model")
makeEntitiesMigration "297"
$(modelFile "migrations/2022_07_24_project_create.model")
model_2022_07_24 :: [Entity SqlBackend]
model_2022_07_24 = $(schema "2022_07_24_collab_fulfills")
makeEntitiesMigration "300"
$(modelFile "migrations/2022_07_25_collab_fulfills_mig.model")
makeEntitiesMigration "303"
$(modelFile "migrations/303_2022-08-04_username.model")
@ -599,24 +459,12 @@ makeEntitiesMigration "365"
makeEntitiesMigration "367"
$(modelFile "migrations/367_2022-08-04_repo_actor.model")
model_384_loom :: [Entity SqlBackend]
model_384_loom = $(schema "384_2022-08-04_loom")
model_386_assignee :: [Entity SqlBackend]
model_386_assignee = $(schema "386_2022-08-04_assignee")
makeEntitiesMigration "388"
$(modelFile "migrations/388_2022-08-04_ticket_loom.model")
makeEntitiesMigration "396"
$(modelFile "migrations/396_2022-08-04_repo_dir.model")
model_399_fwder :: [Entity SqlBackend]
model_399_fwder = $(schema "399_2022-08-04_fwder")
model_408_collab_loom :: [Entity SqlBackend]
model_408_collab_loom = $(schema "408_2022-08-04_collab_loom")
makeEntitiesMigration "409"
$(modelFile "migrations/409_2022-08-05_repo_create.model")
@ -626,15 +474,9 @@ makeEntitiesMigration "414"
makeEntitiesMigration "418"
$(modelFile "migrations/418_2022-08-06_follow_actor.model")
model_425_collab_accept :: [Entity SqlBackend]
model_425_collab_accept = $(schema "425_2022-08-21_collab_accept")
makeEntitiesMigration "426"
$(modelFile "migrations/426_2022-08-21_collab_accept_mig.model")
model_428_collab_topic_local :: [Entity SqlBackend]
model_428_collab_topic_local = $(schema "428_2022-08-29_collab_topic_local")
makeEntitiesMigration "429"
$(modelFile "migrations/429_2022-08-30_collab_repo.model")
@ -647,12 +489,6 @@ makeEntitiesMigration "431"
makeEntitiesMigration "447"
$(modelFile "migrations/447_2022-08-30_collab_accept.model")
model_451_collab_remote_accept :: [Entity SqlBackend]
model_451_collab_remote_accept = $(schema "451_2022-08-30_collab_remote_accept")
model_453_collab_receive :: [Entity SqlBackend]
model_453_collab_receive = $(schema "453_2022-09-01_collab_receive")
makeEntitiesMigration "466"
$(modelFile "migrations/466_2022-09-04_collab_topic_repo.model")
@ -665,15 +501,9 @@ makeEntitiesMigration "468"
makeEntitiesMigration "486"
$(modelFile "migrations/486_2022-09-04_collab_enable.model")
model_494_mr_origin :: [Entity SqlBackend]
model_494_mr_origin = $(schema "494_2022-09-17_mr_origin")
makeEntitiesMigration "495"
$(modelFile "migrations/495_2022-09-21_ticket_title.model")
model_497_sigkey :: [Entity SqlBackend]
model_497_sigkey = $(schema "497_2022-09-29_sigkey")
makeEntitiesMigration "498"
$(modelFile "migrations/498_2022-10-03_forwarder.model")

View file

@ -193,6 +193,7 @@ library
-- Vervis.Handler.Workflow
Vervis.KeyFile
Vervis.Migration
Vervis.Migration.Entities
Vervis.Migration.Model
Vervis.Migration.TH
Vervis.Model