mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-28 04:06:22 +00:00
core: postgres migration for knocking; fix previous migration (#5877)
This commit is contained in:
@@ -6,12 +6,14 @@ import Data.List (sortOn)
|
||||
import Data.Text (Text)
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20241220_initial
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20250402_short_links
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20250403_group_scope
|
||||
import Simplex.Messaging.Agent.Store.Shared (Migration (..))
|
||||
|
||||
schemaMigrations :: [(String, Text, Maybe Text)]
|
||||
schemaMigrations =
|
||||
[ ("20241220_initial", m20241220_initial, Nothing),
|
||||
("20250402_short_links", m20250402_short_links, Just down_m20250402_short_links)
|
||||
("20250402_short_links", m20250402_short_links, Just down_m20250402_short_links),
|
||||
("20250403_group_scope", m20250403_group_scope, Just down_m20250403_group_scope)
|
||||
]
|
||||
|
||||
-- | The list of migrations in ascending order by date
|
||||
|
||||
@@ -12,6 +12,7 @@ m20250402_short_links =
|
||||
[r|
|
||||
ALTER TABLE user_contact_links ADD COLUMN short_link_contact BYTEA;
|
||||
ALTER TABLE connections ADD COLUMN short_link_inv BYTEA;
|
||||
ALTER TABLE connections ADD COLUMN via_short_link_contact BYTEA;
|
||||
|]
|
||||
|
||||
down_m20250402_short_links :: Text
|
||||
@@ -20,4 +21,5 @@ down_m20250402_short_links =
|
||||
[r|
|
||||
ALTER TABLE user_contact_links DROP COLUMN short_link_contact;
|
||||
ALTER TABLE connections DROP COLUMN short_link_inv;
|
||||
ALTER TABLE connections DROP COLUMN via_short_link_contact;
|
||||
|]
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Simplex.Chat.Store.Postgres.Migrations.M20250403_group_scope where
|
||||
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import Text.RawString.QQ (r)
|
||||
|
||||
m20250403_group_scope :: Text
|
||||
m20250403_group_scope =
|
||||
T.pack
|
||||
[r|
|
||||
ALTER TABLE group_profiles ADD COLUMN member_admission TEXT;
|
||||
|
||||
ALTER TABLE group_members ADD COLUMN support_chat_ts TIMESTAMPTZ;
|
||||
ALTER TABLE group_members ADD COLUMN support_chat_items_unread BIGINT NOT NULL DEFAULT 0;
|
||||
ALTER TABLE group_members ADD COLUMN support_chat_items_member_attention BIGINT NOT NULL DEFAULT 0;
|
||||
ALTER TABLE group_members ADD COLUMN support_chat_items_mentions BIGINT NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE chat_items ADD COLUMN group_scope_tag TEXT;
|
||||
ALTER TABLE chat_items ADD COLUMN group_scope_group_member_id BIGINT REFERENCES group_members(group_member_id) ON DELETE CASCADE;
|
||||
|
||||
CREATE INDEX idx_chat_items_group_scope_group_member_id ON chat_items(group_scope_group_member_id);
|
||||
|
||||
CREATE INDEX idx_chat_items_group_scope_item_ts ON chat_items(
|
||||
user_id,
|
||||
group_id,
|
||||
group_scope_tag,
|
||||
group_scope_group_member_id,
|
||||
item_ts
|
||||
);
|
||||
|
||||
CREATE INDEX idx_chat_items_group_scope_item_status ON chat_items(
|
||||
user_id,
|
||||
group_id,
|
||||
group_scope_tag,
|
||||
group_scope_group_member_id,
|
||||
item_status,
|
||||
item_ts
|
||||
);
|
||||
|]
|
||||
|
||||
down_m20250403_group_scope :: Text
|
||||
down_m20250403_group_scope =
|
||||
T.pack
|
||||
[r|
|
||||
DROP INDEX idx_chat_items_group_scope_item_status;
|
||||
|
||||
DROP INDEX idx_chat_items_group_scope_item_ts;
|
||||
|
||||
DROP INDEX idx_chat_items_group_scope_group_member_id;
|
||||
|
||||
ALTER TABLE chat_items DROP COLUMN group_scope_tag;
|
||||
ALTER TABLE chat_items DROP COLUMN group_scope_group_member_id;
|
||||
|
||||
ALTER TABLE group_members DROP COLUMN support_chat_ts;
|
||||
ALTER TABLE group_members DROP COLUMN support_chat_items_unread;
|
||||
ALTER TABLE group_members DROP COLUMN support_chat_items_member_attention;
|
||||
ALTER TABLE group_members DROP COLUMN support_chat_items_mentions;
|
||||
|
||||
ALTER TABLE group_profiles DROP COLUMN member_admission;
|
||||
|]
|
||||
Reference in New Issue
Block a user