This commit is contained in:
spaced4ndy
2026-04-07 16:40:55 +04:00
parent 7c3feccdc2
commit 626706fd4a
9 changed files with 223 additions and 55 deletions
@@ -28,6 +28,7 @@ import Simplex.Chat.Store.Postgres.Migrations.M20260108_chat_indices
import Simplex.Chat.Store.Postgres.Migrations.M20260122_has_link
import Simplex.Chat.Store.Postgres.Migrations.M20260222_chat_relays
import Simplex.Chat.Store.Postgres.Migrations.M20260403_item_viewed
import Simplex.Chat.Store.Postgres.Migrations.M20260407_channel_comments
import Simplex.Messaging.Agent.Store.Shared (Migration (..))
schemaMigrations :: [(String, Text, Maybe Text)]
@@ -55,7 +56,8 @@ schemaMigrations =
("20260108_chat_indices", m20260108_chat_indices, Just down_m20260108_chat_indices),
("20260122_has_link", m20260122_has_link, Just down_m20260122_has_link),
("20260222_chat_relays", m20260222_chat_relays, Just down_m20260222_chat_relays),
("20260403_item_viewed", m20260403_item_viewed, Just down_m20260403_item_viewed)
("20260403_item_viewed", m20260403_item_viewed, Just down_m20260403_item_viewed),
("20260407_channel_comments", m20260407_channel_comments, Just down_m20260407_channel_comments)
]
-- | The list of migrations in ascending order by date
@@ -0,0 +1,30 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
module Simplex.Chat.Store.Postgres.Migrations.M20260407_channel_comments where
import Data.Text (Text)
import Text.RawString.QQ (r)
m20260407_channel_comments :: Text
m20260407_channel_comments =
[r|
ALTER TABLE chat_items ADD COLUMN parent_chat_item_id BIGINT REFERENCES chat_items ON DELETE CASCADE;
ALTER TABLE chat_items ADD COLUMN comments_total INTEGER NOT NULL DEFAULT 0;
ALTER TABLE chat_items ADD COLUMN comments_disabled SMALLINT NOT NULL DEFAULT 0;
CREATE INDEX idx_chat_items_parent_chat_item_id ON chat_items(parent_chat_item_id);
CREATE INDEX idx_chat_items_parent_item_ts ON chat_items(user_id, group_id, parent_chat_item_id, item_ts);
|]
down_m20260407_channel_comments :: Text
down_m20260407_channel_comments =
[r|
DROP INDEX idx_chat_items_parent_chat_item_id;
DROP INDEX idx_chat_items_parent_item_ts;
ALTER TABLE chat_items DROP COLUMN parent_chat_item_id;
ALTER TABLE chat_items DROP COLUMN comments_total;
ALTER TABLE chat_items DROP COLUMN comments_disabled;
UPDATE group_members SET member_role = 'observer' WHERE member_role = 'commenter';
|]