mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-06-04 01:41:43 +00:00
Merge branch 'master' into chat-relays
This commit is contained in:
@@ -25,7 +25,8 @@ import Simplex.Chat.Store.Postgres.Migrations.M20251117_member_relations_vector
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20251128_migrate_member_relations
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20251230_strict_tables
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20260108_chat_indices
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20260109_chat_relays
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20260122_has_link
|
||||
import Simplex.Chat.Store.Postgres.Migrations.M20260222_chat_relays
|
||||
import Simplex.Messaging.Agent.Store.Shared (Migration (..))
|
||||
|
||||
schemaMigrations :: [(String, Text, Maybe Text)]
|
||||
@@ -51,7 +52,8 @@ schemaMigrations =
|
||||
("20251128_migrate_member_relations", m20251128_migrate_member_relations, Just down_m20251128_migrate_member_relations),
|
||||
("20251230_strict_tables", m20251230_strict_tables, Just down_m20251230_strict_tables),
|
||||
("20260108_chat_indices", m20260108_chat_indices, Just down_m20260108_chat_indices),
|
||||
("20260109_chat_relays", m20260109_chat_relays, Just down_m20260109_chat_relays)
|
||||
("20260122_has_link", m20260122_has_link, Just down_m20260122_has_link),
|
||||
("20260222_chat_relays", m20260222_chat_relays, Just down_m20260222_chat_relays)
|
||||
]
|
||||
|
||||
-- | The list of migrations in ascending order by date
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Simplex.Chat.Store.Postgres.Migrations.M20260122_has_link where
|
||||
|
||||
import Data.Text (Text)
|
||||
import Text.RawString.QQ (r)
|
||||
|
||||
m20260122_has_link :: Text
|
||||
m20260122_has_link =
|
||||
[r|
|
||||
ALTER TABLE chat_items ADD COLUMN has_link SMALLINT NOT NULL DEFAULT 0;
|
||||
|
||||
UPDATE chat_items SET msg_content_tag = 'text' WHERE msg_content_tag = 'liveText';
|
||||
|
||||
UPDATE chat_items SET has_link = 1
|
||||
WHERE msg_content_tag = 'link' OR item_text LIKE '%https://%';
|
||||
|
||||
CREATE INDEX idx_chat_items_groups_has_link_item_ts ON chat_items(user_id, group_id, has_link, item_ts);
|
||||
CREATE INDEX idx_chat_items_contacts_has_link_created_at ON chat_items(user_id, contact_id, has_link, created_at);
|
||||
CREATE INDEX idx_chat_items_note_folder_has_link_created_at ON chat_items(user_id, note_folder_id, has_link, created_at);
|
||||
|]
|
||||
|
||||
down_m20260122_has_link :: Text
|
||||
down_m20260122_has_link =
|
||||
[r|
|
||||
DROP INDEX idx_chat_items_note_folder_has_link_created_at;
|
||||
DROP INDEX idx_chat_items_contacts_has_link_created_at;
|
||||
DROP INDEX idx_chat_items_groups_has_link_item_ts;
|
||||
|
||||
ALTER TABLE chat_items DROP COLUMN has_link;
|
||||
|]
|
||||
+5
-5
@@ -1,13 +1,13 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Simplex.Chat.Store.Postgres.Migrations.M20260109_chat_relays where
|
||||
module Simplex.Chat.Store.Postgres.Migrations.M20260222_chat_relays where
|
||||
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import Text.RawString.QQ (r)
|
||||
|
||||
m20260109_chat_relays :: Text
|
||||
m20260109_chat_relays =
|
||||
m20260222_chat_relays :: Text
|
||||
m20260222_chat_relays =
|
||||
T.pack
|
||||
[r|
|
||||
CREATE TABLE chat_relays(
|
||||
@@ -59,8 +59,8 @@ CREATE INDEX idx_group_relays_chat_relay_id ON group_relays(chat_relay_id);
|
||||
ALTER TABLE group_members ADD COLUMN relay_link BYTEA;
|
||||
|]
|
||||
|
||||
down_m20260109_chat_relays :: Text
|
||||
down_m20260109_chat_relays =
|
||||
down_m20260222_chat_relays :: Text
|
||||
down_m20260222_chat_relays =
|
||||
T.pack
|
||||
[r|
|
||||
ALTER TABLE users DROP COLUMN is_user_chat_relay;
|
||||
@@ -342,7 +342,8 @@ CREATE TABLE test_chat_schema.chat_items (
|
||||
user_mention smallint DEFAULT 0 NOT NULL,
|
||||
group_scope_tag text,
|
||||
group_scope_group_member_id bigint,
|
||||
show_group_as_sender smallint DEFAULT 0 NOT NULL
|
||||
show_group_as_sender smallint DEFAULT 0 NOT NULL,
|
||||
has_link smallint DEFAULT 0 NOT NULL
|
||||
);
|
||||
|
||||
|
||||
@@ -1886,6 +1887,10 @@ CREATE INDEX idx_chat_items_contacts_created_at ON test_chat_schema.chat_items U
|
||||
|
||||
|
||||
|
||||
CREATE INDEX idx_chat_items_contacts_has_link_created_at ON test_chat_schema.chat_items USING btree (user_id, contact_id, has_link, created_at);
|
||||
|
||||
|
||||
|
||||
CREATE INDEX idx_chat_items_contacts_msg_content_tag_created_at ON test_chat_schema.chat_items USING btree (user_id, contact_id, msg_content_tag, created_at);
|
||||
|
||||
|
||||
@@ -1946,6 +1951,10 @@ CREATE INDEX idx_chat_items_groups ON test_chat_schema.chat_items USING btree (u
|
||||
|
||||
|
||||
|
||||
CREATE INDEX idx_chat_items_groups_has_link_item_ts ON test_chat_schema.chat_items USING btree (user_id, group_id, has_link, item_ts);
|
||||
|
||||
|
||||
|
||||
CREATE INDEX idx_chat_items_groups_history ON test_chat_schema.chat_items USING btree (user_id, group_id, include_in_history, item_deleted, item_ts, chat_item_id);
|
||||
|
||||
|
||||
@@ -1974,6 +1983,10 @@ CREATE INDEX idx_chat_items_item_status ON test_chat_schema.chat_items USING btr
|
||||
|
||||
|
||||
|
||||
CREATE INDEX idx_chat_items_note_folder_has_link_created_at ON test_chat_schema.chat_items USING btree (user_id, note_folder_id, has_link, created_at);
|
||||
|
||||
|
||||
|
||||
CREATE INDEX idx_chat_items_note_folder_msg_content_tag_created_at ON test_chat_schema.chat_items USING btree (user_id, note_folder_id, msg_content_tag, created_at);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user