diff --git a/cassandra-schema.cql b/cassandra-schema.cql index f55cadd4a6..b2cf569a01 100644 --- a/cassandra-schema.cql +++ b/cassandra-schema.cql @@ -1085,7 +1085,7 @@ CREATE TABLE brig_test.provider ( CREATE TABLE brig_test.user_keys ( key text PRIMARY KEY, user uuid -) WITH bloom_filter_fp_chance = 0.01 +) WITH bloom_filter_fp_chance = 0.1 AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} AND comment = '' AND compaction = {'class': 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'} @@ -1126,7 +1126,7 @@ CREATE TABLE brig_test.invitee_info ( invitee uuid PRIMARY KEY, conv uuid, inviter uuid -) WITH bloom_filter_fp_chance = 0.01 +) WITH bloom_filter_fp_chance = 0.1 AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} AND comment = '' AND compaction = {'class': 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'} @@ -1292,7 +1292,7 @@ CREATE TABLE brig_test.user ( sso_id text, status int, team uuid -) WITH bloom_filter_fp_chance = 0.01 +) WITH bloom_filter_fp_chance = 0.1 AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} AND comment = '' AND compaction = {'class': 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'} @@ -1400,7 +1400,7 @@ CREATE TABLE brig_test.password_reset ( retries int, timeout timestamp, user uuid -) WITH bloom_filter_fp_chance = 0.01 +) WITH bloom_filter_fp_chance = 0.1 AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} AND comment = '' AND compaction = {'class': 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'} @@ -1515,7 +1515,7 @@ CREATE TABLE brig_test.connection ( status int, PRIMARY KEY (left, right) ) WITH CLUSTERING ORDER BY (right ASC) - AND bloom_filter_fp_chance = 0.01 + AND bloom_filter_fp_chance = 0.1 AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} AND comment = '' AND compaction = {'class': 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'} @@ -1586,7 +1586,7 @@ CREATE TABLE brig_test.activation_keys ( key_type ascii, retries int, user uuid -) WITH bloom_filter_fp_chance = 0.01 +) WITH bloom_filter_fp_chance = 0.1 AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} AND comment = '' AND compaction = {'class': 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'} diff --git a/changelog.d/5-internal/brig-schema-init b/changelog.d/5-internal/brig-schema-init new file mode 100644 index 0000000000..53f8738c65 --- /dev/null +++ b/changelog.d/5-internal/brig-schema-init @@ -0,0 +1 @@ +Make brig-schema a little faster by merging the first 34 schema migrations on fresh installations. diff --git a/services/brig/brig.cabal b/services/brig/brig.cabal index eba9741798..23fa66e595 100644 --- a/services/brig/brig.cabal +++ b/services/brig/brig.cabal @@ -621,37 +621,6 @@ executable brig-schema -- cabal-fmt: expand schema/src other-modules: Main - V10 - V11 - V12 - V13 - V14 - V15 - V16 - V17 - V18 - V19 - V20 - V21 - V22 - V23 - V24 - V25 - V28 - V29 - V30 - V31 - V32 - V33 - V34 - V35 - V36 - V37 - V38 - V39 - V40 - V41 - V42 V43 V44 V45 @@ -683,7 +652,6 @@ executable brig-schema V71_AddTableVCodesThrottle V72_AddNonceTable V73_ReplaceNonceTable - V9 V_FUTUREWORK hs-source-dirs: schema/src diff --git a/services/brig/schema/src/Main.hs b/services/brig/schema/src/Main.hs index db7ca577b4..e04a47faf6 100644 --- a/services/brig/schema/src/Main.hs +++ b/services/brig/schema/src/Main.hs @@ -22,36 +22,6 @@ import Control.Exception (finally) import Imports import qualified System.Logger.Extended as Log import Util.Options -import qualified V10 -import qualified V11 -import qualified V12 -import qualified V13 -import qualified V14 -import qualified V15 -import qualified V16 -import qualified V17 -import qualified V18 -import qualified V19 -import qualified V20 -import qualified V21 -import qualified V22 -import qualified V23 -import qualified V24 -import qualified V28 -import qualified V29 -import qualified V30 -import qualified V31 -import qualified V32 -import qualified V33 -import qualified V34 -import qualified V35 -import qualified V36 -import qualified V37 -import qualified V38 -import qualified V39 -import qualified V40 -import qualified V41 -import qualified V42 import qualified V43 import qualified V44 import qualified V45 @@ -83,7 +53,6 @@ import qualified V70_UserEmailUnvalidated import qualified V71_AddTableVCodesThrottle import qualified V72_AddNonceTable import qualified V73_ReplaceNonceTable -import qualified V9 main :: IO () main = do @@ -94,38 +63,7 @@ main = do migrateSchema l o - [ V9.migration, - V10.migration, - V11.migration, - V12.migration, - V13.migration, - V14.migration, - V15.migration, - V16.migration, - V17.migration, - V18.migration, - V19.migration, - V20.migration, - V21.migration, - V22.migration, - V23.migration, - V24.migration, - V28.migration, - V29.migration, - V30.migration, - V31.migration, - V32.migration, - V33.migration, - V34.migration, - V35.migration, - V36.migration, - V37.migration, - V38.migration, - V39.migration, - V40.migration, - V41.migration, - V42.migration, - V43.migration, + [ V43.migration, V44.migration, V45.migration, V46.migration, diff --git a/services/brig/schema/src/V10.hs b/services/brig/schema/src/V10.hs deleted file mode 100644 index ee254706c5..0000000000 --- a/services/brig/schema/src/V10.hs +++ /dev/null @@ -1,68 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V10 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 10 "Switch to leveled compaction" $ do - void $ - schema' - [r| - alter columnfamily user with compaction = { 'class' : 'LeveledCompactionStrategy' }; - |] - void $ - schema' - [r| - alter columnfamily user_keys with compaction = { 'class' : 'LeveledCompactionStrategy' }; - |] - void $ - schema' - [r| - alter columnfamily activation_keys with compaction = { 'class' : 'LeveledCompactionStrategy' }; - |] - void $ - schema' - [r| - alter columnfamily password_reset with compaction = { 'class' : 'LeveledCompactionStrategy' }; - |] - void $ - schema' - [r| - alter columnfamily push with compaction = { 'class' : 'LeveledCompactionStrategy' }; - |] - void $ - schema' - [r| - alter columnfamily connection with compaction = { 'class' : 'LeveledCompactionStrategy' }; - |] - void $ - schema' - [r| - alter columnfamily invitation with compaction = { 'class' : 'LeveledCompactionStrategy' }; - |] - void $ - schema' - [r| - alter columnfamily invitee_info with compaction = { 'class' : 'LeveledCompactionStrategy' }; - |] diff --git a/services/brig/schema/src/V11.hs b/services/brig/schema/src/V11.hs deleted file mode 100644 index 52d65e926f..0000000000 --- a/services/brig/schema/src/V11.hs +++ /dev/null @@ -1,33 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V11 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 11 "Add user.status column" $ do - void $ - schema' - [r| - alter columnfamily user add status int; - |] diff --git a/services/brig/schema/src/V12.hs b/services/brig/schema/src/V12.hs deleted file mode 100644 index c1195e9fdd..0000000000 --- a/services/brig/schema/src/V12.hs +++ /dev/null @@ -1,68 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V12 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 12 "Lower gc_grace_seconds on all CFs to 4 days" $ do - void $ - schema' - [r| - alter columnfamily user with gc_grace_seconds = 345600; - |] - void $ - schema' - [r| - alter columnfamily user_keys with gc_grace_seconds = 345600; - |] - void $ - schema' - [r| - alter columnfamily activation_keys with gc_grace_seconds = 345600; - |] - void $ - schema' - [r| - alter columnfamily password_reset with gc_grace_seconds = 345600; - |] - void $ - schema' - [r| - alter columnfamily push with gc_grace_seconds = 345600; - |] - void $ - schema' - [r| - alter columnfamily connection with gc_grace_seconds = 345600; - |] - void $ - schema' - [r| - alter columnfamily invitation with gc_grace_seconds = 345600; - |] - void $ - schema' - [r| - alter columnfamily invitee_info with gc_grace_seconds = 345600; - |] diff --git a/services/brig/schema/src/V13.hs b/services/brig/schema/src/V13.hs deleted file mode 100644 index ce17a5fda6..0000000000 --- a/services/brig/schema/src/V13.hs +++ /dev/null @@ -1,44 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V13 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 13 "Introduce reverse push CF (user_push) and remove index from push" $ do - void $ - schema' - [r| - create columnfamily if not exists user_push - ( usr uuid -- user id - , ptoken text -- token - , app text -- application - , transport int -- transport type (0 = GCM, 1 = APNS) - , primary key (usr, ptoken, app, transport) - ); - |] - void $ - schema' - [r| - drop index if exists push_usr_key; - |] diff --git a/services/brig/schema/src/V14.hs b/services/brig/schema/src/V14.hs deleted file mode 100644 index 40ada092cd..0000000000 --- a/services/brig/schema/src/V14.hs +++ /dev/null @@ -1,68 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V14 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 14 "Increase gc_grace_seconds back to 10 days" $ do - void $ - schema' - [r| - alter columnfamily user with gc_grace_seconds = 864000; - |] - void $ - schema' - [r| - alter columnfamily user_keys with gc_grace_seconds = 864000; - |] - void $ - schema' - [r| - alter columnfamily activation_keys with gc_grace_seconds = 864000; - |] - void $ - schema' - [r| - alter columnfamily password_reset with gc_grace_seconds = 864000; - |] - void $ - schema' - [r| - alter columnfamily push with gc_grace_seconds = 864000; - |] - void $ - schema' - [r| - alter columnfamily connection with gc_grace_seconds = 864000; - |] - void $ - schema' - [r| - alter columnfamily invitation with gc_grace_seconds = 864000; - |] - void $ - schema' - [r| - alter columnfamily invitee_info with gc_grace_seconds = 864000; - |] diff --git a/services/brig/schema/src/V15.hs b/services/brig/schema/src/V15.hs deleted file mode 100644 index 485304b56e..0000000000 --- a/services/brig/schema/src/V15.hs +++ /dev/null @@ -1,33 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V15 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 15 "Add user.tracking_id" $ do - void $ - schema' - [r| - alter columnfamily user add tracking_id uuid; - |] diff --git a/services/brig/schema/src/V16.hs b/services/brig/schema/src/V16.hs deleted file mode 100644 index 2601277699..0000000000 --- a/services/brig/schema/src/V16.hs +++ /dev/null @@ -1,33 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V16 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 16 "Drop push column family" $ do - void $ - schema' - [r| - drop columnfamily if exists push; - |] diff --git a/services/brig/schema/src/V17.hs b/services/brig/schema/src/V17.hs deleted file mode 100644 index 07b42e7f75..0000000000 --- a/services/brig/schema/src/V17.hs +++ /dev/null @@ -1,34 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V17 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 17 "Drop user_push column family" $ do - -- 'user_push' has been moved to gundeck - void $ - schema' - [r| - drop columnfamily if exists user_push; - |] diff --git a/services/brig/schema/src/V18.hs b/services/brig/schema/src/V18.hs deleted file mode 100644 index f82bb74cf1..0000000000 --- a/services/brig/schema/src/V18.hs +++ /dev/null @@ -1,51 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V18 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 18 "Add prekeys" $ do - void $ - schema' - [r| - create columnfamily if not exists clients - ( user uuid - , client text - , tstamp timestamp - , type int - , label text - , primary key (user, client) - ); - |] - void $ - schema' - [r| - create columnfamily if not exists prekeys - ( user uuid - , client text - , key int - , data text - , primary key (user, client, key) - ); - |] diff --git a/services/brig/schema/src/V19.hs b/services/brig/schema/src/V19.hs deleted file mode 100644 index 47aec633e4..0000000000 --- a/services/brig/schema/src/V19.hs +++ /dev/null @@ -1,38 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V19 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 19 "Add properties" $ do - void $ - schema' - [r| - create columnfamily if not exists properties - ( user uuid - , key ascii - , value blob - , primary key (user, key) - ); - |] diff --git a/services/brig/schema/src/V20.hs b/services/brig/schema/src/V20.hs deleted file mode 100644 index 1ab8756f69..0000000000 --- a/services/brig/schema/src/V20.hs +++ /dev/null @@ -1,33 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V20 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 20 "Add activation_keys.challenge" $ do - void $ - schema' - [r| - alter columnfamily activation_keys add challenge ascii; - |] diff --git a/services/brig/schema/src/V21.hs b/services/brig/schema/src/V21.hs deleted file mode 100644 index 0e3a9becf1..0000000000 --- a/services/brig/schema/src/V21.hs +++ /dev/null @@ -1,33 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V21 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 21 "Remove password_reset.email" $ do - void $ - schema' - [r| - alter columnfamily password_reset drop email; - |] diff --git a/services/brig/schema/src/V22.hs b/services/brig/schema/src/V22.hs deleted file mode 100644 index c9fc9a8cac..0000000000 --- a/services/brig/schema/src/V22.hs +++ /dev/null @@ -1,39 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V22 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 22 "Add login_codes" $ do - void $ - schema' - [r| - create columnfamily if not exists login_codes - ( user uuid - , code text - , retries int - , timeout timestamp - , primary key (user) - ); - |] diff --git a/services/brig/schema/src/V23.hs b/services/brig/schema/src/V23.hs deleted file mode 100644 index 2214512098..0000000000 --- a/services/brig/schema/src/V23.hs +++ /dev/null @@ -1,38 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V23 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 23 "Add password_reset.retries and timeout" $ do - void $ - schema' - [r| - alter columnfamily password_reset add retries int; - |] - void $ - schema' - [r| - alter columnfamily password_reset add timeout timestamp; - |] diff --git a/services/brig/schema/src/V24.hs b/services/brig/schema/src/V24.hs deleted file mode 100644 index a080397369..0000000000 --- a/services/brig/schema/src/V24.hs +++ /dev/null @@ -1,38 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V24 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 24 "Add user.language and user.country" $ do - void $ - schema' - [r| - alter columnfamily user add language ascii; - |] - void $ - schema' - [r| - alter columnfamily user add country ascii; - |] diff --git a/services/brig/schema/src/V25.hs b/services/brig/schema/src/V25.hs deleted file mode 100644 index bbafe532b9..0000000000 --- a/services/brig/schema/src/V25.hs +++ /dev/null @@ -1,30 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V25 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 25 "Change client IDs from ascii to text" $ do - schema' [r| alter columnfamily clients alter client type text; |] - schema' [r| alter columnfamily prekeys alter client type text; |] diff --git a/services/brig/schema/src/V28.hs b/services/brig/schema/src/V28.hs deleted file mode 100644 index aa4248485c..0000000000 --- a/services/brig/schema/src/V28.hs +++ /dev/null @@ -1,30 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V28 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 28 "Add additional client properties" $ do - schema' [r| alter columnfamily clients add class int; |] - schema' [r| alter columnfamily clients add cookie text; |] diff --git a/services/brig/schema/src/V29.hs b/services/brig/schema/src/V29.hs deleted file mode 100644 index 3a371af08a..0000000000 --- a/services/brig/schema/src/V29.hs +++ /dev/null @@ -1,56 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V29 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 29 "Create new invitations tables" $ do - void $ - schema' - [r| - drop columnfamily if exists invitation |] - void $ - schema' - [r| - create columnfamily if not exists invitation - ( inviter uuid -- user id that created the invitation - , id uuid -- invitation id reference (relevant for inviter) - , code ascii -- code of the invitation (known only by invitee) - , email text -- email of the user invited - , phone text -- phone of the user invited - , created_at timestamp -- time this invitation was created - , name text -- name of the invitee - , primary key (inviter, id) - ); - |] - void $ - schema' - [r| - create columnfamily if not exists invitation_info - ( code ascii -- code of the invitation (known only by invitee) - , inviter uuid -- user id that created the invitation - , id uuid -- invitation id reference (relevant for inviter) - , primary key (code) - ); - |] diff --git a/services/brig/schema/src/V30.hs b/services/brig/schema/src/V30.hs deleted file mode 100644 index f092709361..0000000000 --- a/services/brig/schema/src/V30.hs +++ /dev/null @@ -1,31 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V30 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 30 "Add even more client properties" $ do - schema' [r| alter columnfamily clients add ip inet; |] - schema' [r| alter columnfamily clients add lat double; |] - schema' [r| alter columnfamily clients add lon double; |] diff --git a/services/brig/schema/src/V31.hs b/services/brig/schema/src/V31.hs deleted file mode 100644 index 2ff9f63ffa..0000000000 --- a/services/brig/schema/src/V31.hs +++ /dev/null @@ -1,30 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V31 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = - Migration 31 "Add model to clients" $ - schema' [r| alter columnfamily clients add model text; |] diff --git a/services/brig/schema/src/V32.hs b/services/brig/schema/src/V32.hs deleted file mode 100644 index 83d31d9507..0000000000 --- a/services/brig/schema/src/V32.hs +++ /dev/null @@ -1,39 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V32 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = - Migration 32 "Add generic verification codes" $ - schema' - [r| - create columnfamily if not exists codes - ( user uuid - , scope int - , code text - , retries int - , primary key (user, scope) - ); - |] diff --git a/services/brig/schema/src/V33.hs b/services/brig/schema/src/V33.hs deleted file mode 100644 index 4daf85ddab..0000000000 --- a/services/brig/schema/src/V33.hs +++ /dev/null @@ -1,39 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V33 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 33 "Add user.assets column" $ do - schema' - [r| - create type if not exists asset - ( typ int - , key text - ); - |] - schema' - [r| - alter columnfamily user add assets list>; - |] diff --git a/services/brig/schema/src/V34.hs b/services/brig/schema/src/V34.hs deleted file mode 100644 index 8fffe0e843..0000000000 --- a/services/brig/schema/src/V34.hs +++ /dev/null @@ -1,47 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V34 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = - Migration 34 "Add vcodes table" $ - -- Supposed to cover all existing use-cases for short-lived - -- verification codes sent either by e-mail, sms or voice call, - -- eventually superseding the 'activation_keys', 'login_codes', - -- 'password_reset' and 'codes' tables. - schema' - [r| - create table if not exists vcodes - ( key ascii -- opaque 'email' or 'phone' - , scope int - , value ascii -- secret value - , retries int -- attempts left - , email text -- email address (xor phone) - , phone text -- phone number (xor email) - , account uuid -- optional associated account ID - , primary key (key, scope) - ) with compaction = {'class': 'LeveledCompactionStrategy'} - and gc_grace_seconds = 0; - |] diff --git a/services/brig/schema/src/V35.hs b/services/brig/schema/src/V35.hs deleted file mode 100644 index 0a8a197f64..0000000000 --- a/services/brig/schema/src/V35.hs +++ /dev/null @@ -1,93 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V35 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 35 "Add service provider tables" $ do - schema' - [r| - create table if not exists provider - ( id uuid - , name text - , email text - , password blob - , url blob - , descr text - , primary key (id) - ) with compaction = {'class': 'LeveledCompactionStrategy'}; - |] - schema' - [r| - create table if not exists provider_keys - ( key text - , provider uuid - , primary key (key) - ) with compaction = {'class': 'LeveledCompactionStrategy'}; - |] - schema' - [r| - create type if not exists pubkey - ( typ int - , size int - , pem blob - ); - |] - schema' - [r| - create table if not exists service - ( provider uuid - , id uuid - , name text - , descr text - , base_url blob - , auth_tokens list - , pubkeys list> - , fingerprints list - , assets list> - , tags set - , enabled boolean - , primary key (provider, id) - ) with compaction = {'class': 'LeveledCompactionStrategy'}; - |] - schema' - [r| - create table if not exists service_tag - ( bucket int - , tag bigint - , name text - , service uuid - , provider uuid - , primary key ((bucket, tag), name, service) - ) with clustering order by (name asc, service asc) - and compaction = {'class': 'LeveledCompactionStrategy'}; - |] - schema' - [r| - alter table user add provider uuid; - |] - schema' - [r| - alter table user add service uuid; - |] diff --git a/services/brig/schema/src/V36.hs b/services/brig/schema/src/V36.hs deleted file mode 100644 index 97f71bfbbb..0000000000 --- a/services/brig/schema/src/V36.hs +++ /dev/null @@ -1,33 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V36 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = - Migration 36 "Add asset.size attribute" $ - schema' - [r| - alter type asset add size int; - |] diff --git a/services/brig/schema/src/V37.hs b/services/brig/schema/src/V37.hs deleted file mode 100644 index afc5c0032e..0000000000 --- a/services/brig/schema/src/V37.hs +++ /dev/null @@ -1,38 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V37 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = - Migration 37 "Add budget table" $ - schema' - [r| - create table if not exists budget - ( key text - , budget int - , primary key (key) - ) with compaction = {'class': 'LeveledCompactionStrategy'} - and gc_grace_seconds = 0; - |] diff --git a/services/brig/schema/src/V38.hs b/services/brig/schema/src/V38.hs deleted file mode 100644 index 6eca54ec75..0000000000 --- a/services/brig/schema/src/V38.hs +++ /dev/null @@ -1,49 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V38 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 38 "Add user handles" $ do - schema' - [r| - create table if not exists unique_claims - ( value text - , claims set - , primary key (value) - ) with compaction = {'class': 'LeveledCompactionStrategy'} - and gc_grace_seconds = 0; - |] - schema' - [r| - create table if not exists user_handle - ( handle text - , user uuid - , primary key (handle) - ) with compaction = {'class': 'LeveledCompactionStrategy'}; - |] - schema' - [r| - alter table user add handle text; - |] diff --git a/services/brig/schema/src/V39.hs b/services/brig/schema/src/V39.hs deleted file mode 100644 index 2a9ec5b7e2..0000000000 --- a/services/brig/schema/src/V39.hs +++ /dev/null @@ -1,42 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V39 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = - Migration 39 "Add user_cookies table" $ - schema' - [r| - create table if not exists user_cookies - ( user uuid - , expires timestamp - , id bigint - , label text - , type int - , created timestamp - , succ_id bigint - , primary key (user, expires, id) - ) with compaction = {'class': 'LeveledCompactionStrategy'}; - |] diff --git a/services/brig/schema/src/V40.hs b/services/brig/schema/src/V40.hs deleted file mode 100644 index 62b2f0fddd..0000000000 --- a/services/brig/schema/src/V40.hs +++ /dev/null @@ -1,38 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V40 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = - Migration 40 "Add hashed userkeys table" $ - schema' - [r| - create table if not exists user_keys_hash - ( key blob - , key_type int -- hash type (0 = PHONE, 1 = EMAIL) - , user uuid - , primary key (key) - ) with compaction = {'class': 'LeveledCompactionStrategy'}; - |] diff --git a/services/brig/schema/src/V41.hs b/services/brig/schema/src/V41.hs deleted file mode 100644 index 0d86c8fbe9..0000000000 --- a/services/brig/schema/src/V41.hs +++ /dev/null @@ -1,33 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V41 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = - Migration 41 "Add searchable field to user table" $ - schema' - [r| - alter table user add searchable boolean - |] diff --git a/services/brig/schema/src/V42.hs b/services/brig/schema/src/V42.hs deleted file mode 100644 index 708134320b..0000000000 --- a/services/brig/schema/src/V42.hs +++ /dev/null @@ -1,34 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V42 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = - Migration 42 "Remove user.tracking_id" $ - void $ - schema' - [r| - alter columnfamily user drop tracking_id; - |] diff --git a/services/brig/schema/src/V43.hs b/services/brig/schema/src/V43.hs index 842461bdb3..288ea41b2e 100644 --- a/services/brig/schema/src/V43.hs +++ b/services/brig/schema/src/V43.hs @@ -25,7 +25,368 @@ import Imports import Text.RawString.QQ migration :: Migration -migration = Migration 43 "Add team invitations" $ do +migration = Migration 43 "Initial brig schema at time of open-sourcing wire-server in 2017" $ do + void $ + schema' + [r| + create columnfamily if not exists user + ( id uuid + , accent list -- accent colour RGBA + , accent_id int -- accent colour ID + , name text -- user name + , picture list -- user picture(s) (asset metadata) + , email text + , phone text + , password blob -- pw hash + , activated boolean + , status int + , language ascii + , country ascii + , primary key (id) + ) with compaction = {'class': 'LeveledCompactionStrategy'}; + |] + void $ + schema' + [r| + -- verified, 'unique' user attributes + create columnfamily if not exists user_keys + ( key text -- email or phone number + , user uuid -- user ID + , primary key (key) + ) with compaction = {'class': 'LeveledCompactionStrategy'}; + |] + void $ + schema' + [r| + -- (temporary) activation keys + create columnfamily if not exists activation_keys + ( key ascii -- opaque version of key_text + , key_type ascii -- ("email" or "phone") + , key_text text -- the plain 'key' (phone or email) + , code ascii -- random code + , user uuid + , retries int -- # of remaining attempts + , challenge ascii + , primary key (key) + ) with compaction = {'class': 'LeveledCompactionStrategy'}; + |] + void $ + schema' + [r| + -- (temporary) password reset codes + create columnfamily if not exists password_reset + ( key ascii -- opaque version of the user ID + , code ascii -- random code + , user uuid + , primary key (key) + ) with compaction = {'class': 'LeveledCompactionStrategy'}; + |] + void $ + schema' + [r| + create columnfamily if not exists connection + ( left uuid -- user id "from" in the relation + , right uuid -- user id "to" in the relation + , status int -- relation type (0 = ACCEPTED, 1 = BLOCKED, 2 = PENDING, 3 = IGNORED) + , last_update timestamp -- last time this relation was updated + , message text -- message sent together with the request + , conv uuid -- conv id between the 2 (if needed) + , primary key (left, right) + ) with compaction = {'class': 'LeveledCompactionStrategy'}; + |] + void $ + schema' + [r| + create index if not exists conn_status on connection (status); + |] + void $ + schema' + [r| + create columnfamily if not exists invitee_info + ( invitee uuid -- user id generated with the invitation + , inviter uuid -- user id that created the invitation + , conv uuid -- conv id between the 2 + , primary key (invitee) + ) with compaction = {'class': 'LeveledCompactionStrategy'}; + |] + + -- Add prekeys + void $ + schema' + [r| + create columnfamily if not exists clients + ( user uuid + , client text + , tstamp timestamp + , type int + , label text + , primary key (user, client) + ); + |] + void $ + schema' + [r| + create columnfamily if not exists prekeys + ( user uuid + , client text + , key int + , data text + , primary key (user, client, key) + ); + |] + + -- Add properties + void $ + schema' + [r| + create columnfamily if not exists properties + ( user uuid + , key ascii + , value blob + , primary key (user, key) + ); + |] + + -- Add login_codes + void $ + schema' + [r| + create columnfamily if not exists login_codes + ( user uuid + , code text + , retries int + , timeout timestamp + , primary key (user) + ); + |] + + -- Add password_reset.retries and timeout + void $ + schema' + [r| + alter columnfamily password_reset add retries int; + |] + void $ + schema' + [r| + alter columnfamily password_reset add timeout timestamp; + |] + + -- Add additional client properties + schema' [r| alter columnfamily clients add class int; |] + schema' [r| alter columnfamily clients add cookie text; |] + + -- Create new invitations tables + void $ + schema' + [r| + create columnfamily if not exists invitation + ( inviter uuid -- user id that created the invitation + , id uuid -- invitation id reference (relevant for inviter) + , code ascii -- code of the invitation (known only by invitee) + , email text -- email of the user invited + , phone text -- phone of the user invited + , created_at timestamp -- time this invitation was created + , name text -- name of the invitee + , primary key (inviter, id) + ); + |] + void $ + schema' + [r| + create columnfamily if not exists invitation_info + ( code ascii -- code of the invitation (known only by invitee) + , inviter uuid -- user id that created the invitation + , id uuid -- invitation id reference (relevant for inviter) + , primary key (code) + ); + |] + + -- Add even more client properties + schema' [r| alter columnfamily clients add ip inet; |] + schema' [r| alter columnfamily clients add lat double; |] + schema' [r| alter columnfamily clients add lon double; |] + -- Add model to clients + schema' [r| alter columnfamily clients add model text; |] + -- Add generic verification codes + schema' + [r| + create columnfamily if not exists codes + ( user uuid + , scope int + , code text + , retries int + , primary key (user, scope) + ); + |] + + -- Add user.assets column + schema' + [r| + create type if not exists asset + ( typ int + , key text + ); + |] + schema' + [r| + alter columnfamily user add assets list>; + |] + -- Add vcodes table + -- Supposed to cover all existing use-cases for short-lived + -- verification codes sent either by e-mail, sms or voice call, + -- eventually superseding the 'activation_keys', 'login_codes', + -- 'password_reset' and 'codes' tables. + schema' + [r| + create table if not exists vcodes + ( key ascii -- opaque 'email' or 'phone' + , scope int + , value ascii -- secret value + , retries int -- attempts left + , email text -- email address (xor phone) + , phone text -- phone number (xor email) + , account uuid -- optional associated account ID + , primary key (key, scope) + ) with compaction = {'class': 'LeveledCompactionStrategy'} + and gc_grace_seconds = 0; + |] + + -- Add service provider tables + schema' + [r| + create table if not exists provider + ( id uuid + , name text + , email text + , password blob + , url blob + , descr text + , primary key (id) + ) with compaction = {'class': 'LeveledCompactionStrategy'}; + |] + schema' + [r| + create table if not exists provider_keys + ( key text + , provider uuid + , primary key (key) + ) with compaction = {'class': 'LeveledCompactionStrategy'}; + |] + schema' + [r| + create type if not exists pubkey + ( typ int + , size int + , pem blob + ); + |] + schema' + [r| + create table if not exists service + ( provider uuid + , id uuid + , name text + , descr text + , base_url blob + , auth_tokens list + , pubkeys list> + , fingerprints list + , assets list> + , tags set + , enabled boolean + , primary key (provider, id) + ) with compaction = {'class': 'LeveledCompactionStrategy'}; + |] + schema' + [r| + create table if not exists service_tag + ( bucket int + , tag bigint + , name text + , service uuid + , provider uuid + , primary key ((bucket, tag), name, service) + ) with clustering order by (name asc, service asc) + and compaction = {'class': 'LeveledCompactionStrategy'}; + |] + schema' + [r| + alter table user add provider uuid; + |] + schema' + [r| + alter table user add service uuid; + |] + -- Add asset.size attribute + schema' + [r| + alter type asset add size int; + |] + -- Add budget table + schema' + [r| + create table if not exists budget + ( key text + , budget int + , primary key (key) + ) with compaction = {'class': 'LeveledCompactionStrategy'} + and gc_grace_seconds = 0; + |] + + -- Add user handles + schema' + [r| + create table if not exists unique_claims + ( value text + , claims set + , primary key (value) + ) with compaction = {'class': 'LeveledCompactionStrategy'} + and gc_grace_seconds = 0; + |] + schema' + [r| + create table if not exists user_handle + ( handle text + , user uuid + , primary key (handle) + ) with compaction = {'class': 'LeveledCompactionStrategy'}; + |] + schema' + [r| + alter table user add handle text; + |] + -- Add user_cookies table + schema' + [r| + create table if not exists user_cookies + ( user uuid + , expires timestamp + , id bigint + , label text + , type int + , created timestamp + , succ_id bigint + , primary key (user, expires, id) + ) with compaction = {'class': 'LeveledCompactionStrategy'}; + |] + -- Add hashed userkeys table + schema' + [r| + create table if not exists user_keys_hash + ( key blob + , key_type int -- hash type (0 = PHONE, 1 = EMAIL) + , user uuid + , primary key (key) + ) with compaction = {'class': 'LeveledCompactionStrategy'}; + |] + -- Add searchable field to user table + schema' + [r| + alter table user add searchable boolean + |] + + -- Add team invitations schema' [r| create columnfamily if not exists team_invitation diff --git a/services/brig/schema/src/V9.hs b/services/brig/schema/src/V9.hs deleted file mode 100644 index e398e4b1e2..0000000000 --- a/services/brig/schema/src/V9.hs +++ /dev/null @@ -1,136 +0,0 @@ --- This file is part of the Wire Server implementation. --- --- Copyright (C) 2022 Wire Swiss GmbH --- --- This program is free software: you can redistribute it and/or modify it under --- the terms of the GNU Affero General Public License as published by the Free --- Software Foundation, either version 3 of the License, or (at your option) any --- later version. --- --- This program is distributed in the hope that it will be useful, but WITHOUT --- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS --- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more --- details. --- --- You should have received a copy of the GNU Affero General Public License along --- with this program. If not, see . - -module V9 - ( migration, - ) -where - -import Cassandra.Schema -import Imports -import Text.RawString.QQ - -migration :: Migration -migration = Migration 9 "Initial schema" $ do - void $ - schema' - [r| - create columnfamily if not exists user - ( id uuid - , accent list -- accent colour RGBA - , accent_id int -- accent colour ID - , name text -- user name - , picture list -- user picture(s) (asset metadata) - , email text - , phone text - , password blob -- pw hash - , activated boolean - , primary key (id) - ); - |] - void $ - schema' - [r| - -- verified, 'unique' user attributes - create columnfamily if not exists user_keys - ( key text -- email or phone number - , user uuid -- user ID - , primary key (key) - ); - |] - void $ - schema' - [r| - -- (temporary) activation keys - create columnfamily if not exists activation_keys - ( key ascii -- opaque version of key_text - , key_type ascii -- ("email" or "phone") - , key_text text -- the plain 'key' (phone or email) - , code ascii -- random code - , user uuid - , retries int -- # of remaining attempts - , primary key (key) - ); - |] - void $ - schema' - [r| - -- (temporary) password reset codes - create columnfamily if not exists password_reset - ( key ascii -- opaque version of the user ID - , code ascii -- random code - , user uuid - , email text - , primary key (key) - ); - |] - void $ - schema' - [r| - create columnfamily if not exists push - ( ptoken text -- token - , app text -- application - , transport int -- transport type (0 = GCM, 1 = APNS) - , usr uuid -- user id - , primary key (ptoken, app, transport) - ); - |] - void $ - schema' - [r| - -- TODO: usr is a really bad secondary index! - create index if not exists push_usr_key on push (usr); - |] - void $ - schema' - [r| - create columnfamily if not exists connection - ( left uuid -- user id "from" in the relation - , right uuid -- user id "to" in the relation - , status int -- relation type (0 = ACCEPTED, 1 = BLOCKED, 2 = PENDING, 3 = IGNORED) - , last_update timestamp -- last time this relation was updated - , message text -- message sent together with the request - , conv uuid -- conv id between the 2 (if needed) - , primary key (left, right) - ); - |] - void $ - schema' - [r| - create index if not exists conn_status on connection (status); - |] - void $ - schema' - [r| - create columnfamily if not exists invitation - ( inviter uuid -- user id that created the invitation - , invitee uuid -- user id generated with the invitation - , email text -- email of the user invited - , last_update timestamp -- last time this invitation was updated - , primary key (inviter, email) - ); - |] - void $ - schema' - [r| - create columnfamily if not exists invitee_info - ( invitee uuid -- user id generated with the invitation - , inviter uuid -- user id that created the invitation - , conv uuid -- conv id between the 2 - , primary key (invitee) - ); - |]