mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-28 02:38:44 +00:00
core: public groups - roster of privileged members (#7017)
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
|
||||
module Simplex.Chat.Store.Postgres.Migrations.M20260602_group_roster where
|
||||
|
||||
import Data.Text (Text)
|
||||
import Text.RawString.QQ (r)
|
||||
|
||||
m20260602_group_roster :: Text
|
||||
m20260602_group_roster =
|
||||
[r|
|
||||
ALTER TABLE groups ADD COLUMN roster_version BIGINT;
|
||||
ALTER TABLE groups ADD COLUMN roster_msg_body BYTEA;
|
||||
ALTER TABLE groups ADD COLUMN roster_msg_chat_binding TEXT;
|
||||
ALTER TABLE groups ADD COLUMN roster_msg_signatures BYTEA;
|
||||
ALTER TABLE groups ADD COLUMN roster_sending_owner_gm_id BIGINT;
|
||||
ALTER TABLE groups ADD COLUMN roster_broker_ts TIMESTAMPTZ;
|
||||
ALTER TABLE groups ADD COLUMN roster_blob BYTEA;
|
||||
|
||||
CREATE TABLE rcv_roster_transfers(
|
||||
roster_transfer_id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
||||
group_id BIGINT NOT NULL REFERENCES groups ON DELETE CASCADE,
|
||||
from_member_id BIGINT NOT NULL REFERENCES group_members ON DELETE CASCADE,
|
||||
roster_version BIGINT NOT NULL,
|
||||
roster_digest BYTEA NOT NULL,
|
||||
sending_owner_gm_id BIGINT NOT NULL,
|
||||
broker_ts TIMESTAMPTZ NOT NULL,
|
||||
roster_msg_body BYTEA,
|
||||
roster_msg_chat_binding TEXT,
|
||||
roster_msg_signatures BYTEA,
|
||||
created_at TEXT NOT NULL DEFAULT (now()),
|
||||
updated_at TEXT NOT NULL DEFAULT (now())
|
||||
);
|
||||
CREATE UNIQUE INDEX idx_rcv_roster_transfers_group_id_from_member_id ON rcv_roster_transfers(group_id, from_member_id);
|
||||
CREATE INDEX idx_rcv_roster_transfers_from_member_id ON rcv_roster_transfers(from_member_id);
|
||||
|
||||
ALTER TABLE files ADD COLUMN shared_msg_id BYTEA;
|
||||
ALTER TABLE files ADD COLUMN file_type TEXT NOT NULL DEFAULT 'normal';
|
||||
ALTER TABLE files ADD COLUMN roster_transfer_id BIGINT;
|
||||
CREATE INDEX idx_files_group_id_shared_msg_id ON files(group_id, shared_msg_id);
|
||||
CREATE INDEX idx_files_roster_transfer_id ON files(roster_transfer_id);
|
||||
|]
|
||||
|
||||
down_m20260602_group_roster :: Text
|
||||
down_m20260602_group_roster =
|
||||
[r|
|
||||
DROP INDEX idx_files_roster_transfer_id;
|
||||
DROP INDEX idx_files_group_id_shared_msg_id;
|
||||
ALTER TABLE files DROP COLUMN roster_transfer_id;
|
||||
ALTER TABLE files DROP COLUMN file_type;
|
||||
ALTER TABLE files DROP COLUMN shared_msg_id;
|
||||
|
||||
DROP INDEX idx_rcv_roster_transfers_from_member_id;
|
||||
DROP INDEX idx_rcv_roster_transfers_group_id_from_member_id;
|
||||
DROP TABLE rcv_roster_transfers;
|
||||
|
||||
ALTER TABLE groups DROP COLUMN roster_blob;
|
||||
ALTER TABLE groups DROP COLUMN roster_broker_ts;
|
||||
ALTER TABLE groups DROP COLUMN roster_sending_owner_gm_id;
|
||||
ALTER TABLE groups DROP COLUMN roster_msg_signatures;
|
||||
ALTER TABLE groups DROP COLUMN roster_msg_chat_binding;
|
||||
ALTER TABLE groups DROP COLUMN roster_msg_body;
|
||||
ALTER TABLE groups DROP COLUMN roster_version;
|
||||
|]
|
||||
@@ -752,7 +752,10 @@ CREATE TABLE test_chat_schema.files (
|
||||
file_crypto_key bytea,
|
||||
file_crypto_nonce bytea,
|
||||
note_folder_id bigint,
|
||||
redirect_file_id bigint
|
||||
redirect_file_id bigint,
|
||||
shared_msg_id bytea,
|
||||
file_type text DEFAULT 'normal'::text NOT NULL,
|
||||
roster_transfer_id bigint
|
||||
);
|
||||
|
||||
|
||||
@@ -977,9 +980,16 @@ CREATE TABLE test_chat_schema.groups (
|
||||
public_member_count bigint,
|
||||
relay_request_retries bigint DEFAULT 0 NOT NULL,
|
||||
relay_request_delay bigint DEFAULT 0 NOT NULL,
|
||||
relay_request_execute_at timestamp with time zone DEFAULT '1970-01-01 01:00:00+01'::timestamp with time zone NOT NULL,
|
||||
relay_request_execute_at timestamp with time zone DEFAULT '1970-01-01 04:00:00+04'::timestamp with time zone NOT NULL,
|
||||
relay_inactive_at timestamp with time zone,
|
||||
relay_sent_web_domain text
|
||||
relay_sent_web_domain text,
|
||||
roster_version bigint,
|
||||
roster_msg_body bytea,
|
||||
roster_msg_chat_binding text,
|
||||
roster_msg_signatures bytea,
|
||||
roster_sending_owner_gm_id bigint,
|
||||
roster_broker_ts timestamp with time zone,
|
||||
roster_blob bytea
|
||||
);
|
||||
|
||||
|
||||
@@ -1206,6 +1216,34 @@ CREATE TABLE test_chat_schema.rcv_files (
|
||||
|
||||
|
||||
|
||||
CREATE TABLE test_chat_schema.rcv_roster_transfers (
|
||||
roster_transfer_id bigint NOT NULL,
|
||||
group_id bigint NOT NULL,
|
||||
from_member_id bigint NOT NULL,
|
||||
roster_version bigint NOT NULL,
|
||||
roster_digest bytea NOT NULL,
|
||||
sending_owner_gm_id bigint NOT NULL,
|
||||
broker_ts timestamp with time zone NOT NULL,
|
||||
roster_msg_body bytea,
|
||||
roster_msg_chat_binding text,
|
||||
roster_msg_signatures bytea,
|
||||
created_at text DEFAULT now() NOT NULL,
|
||||
updated_at text DEFAULT now() NOT NULL
|
||||
);
|
||||
|
||||
|
||||
|
||||
ALTER TABLE test_chat_schema.rcv_roster_transfers ALTER COLUMN roster_transfer_id ADD GENERATED ALWAYS AS IDENTITY (
|
||||
SEQUENCE NAME test_chat_schema.rcv_roster_transfers_roster_transfer_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1
|
||||
);
|
||||
|
||||
|
||||
|
||||
CREATE TABLE test_chat_schema.received_probes (
|
||||
received_probe_id bigint NOT NULL,
|
||||
contact_id bigint,
|
||||
@@ -1739,6 +1777,11 @@ ALTER TABLE ONLY test_chat_schema.rcv_files
|
||||
|
||||
|
||||
|
||||
ALTER TABLE ONLY test_chat_schema.rcv_roster_transfers
|
||||
ADD CONSTRAINT rcv_roster_transfers_pkey PRIMARY KEY (roster_transfer_id);
|
||||
|
||||
|
||||
|
||||
ALTER TABLE ONLY test_chat_schema.received_probes
|
||||
ADD CONSTRAINT received_probes_pkey PRIMARY KEY (received_probe_id);
|
||||
|
||||
@@ -2272,10 +2315,18 @@ CREATE INDEX idx_files_group_id ON test_chat_schema.files USING btree (group_id)
|
||||
|
||||
|
||||
|
||||
CREATE INDEX idx_files_group_id_shared_msg_id ON test_chat_schema.files USING btree (group_id, shared_msg_id);
|
||||
|
||||
|
||||
|
||||
CREATE INDEX idx_files_redirect_file_id ON test_chat_schema.files USING btree (redirect_file_id);
|
||||
|
||||
|
||||
|
||||
CREATE INDEX idx_files_roster_transfer_id ON test_chat_schema.files USING btree (roster_transfer_id);
|
||||
|
||||
|
||||
|
||||
CREATE INDEX idx_files_user_id ON test_chat_schema.files USING btree (user_id);
|
||||
|
||||
|
||||
@@ -2448,6 +2499,14 @@ CREATE INDEX idx_rcv_files_group_member_id ON test_chat_schema.rcv_files USING b
|
||||
|
||||
|
||||
|
||||
CREATE INDEX idx_rcv_roster_transfers_from_member_id ON test_chat_schema.rcv_roster_transfers USING btree (from_member_id);
|
||||
|
||||
|
||||
|
||||
CREATE UNIQUE INDEX idx_rcv_roster_transfers_group_id_from_member_id ON test_chat_schema.rcv_roster_transfers USING btree (group_id, from_member_id);
|
||||
|
||||
|
||||
|
||||
CREATE INDEX idx_received_probes_contact_id ON test_chat_schema.received_probes USING btree (contact_id);
|
||||
|
||||
|
||||
@@ -3133,6 +3192,16 @@ ALTER TABLE ONLY test_chat_schema.rcv_files
|
||||
|
||||
|
||||
|
||||
ALTER TABLE ONLY test_chat_schema.rcv_roster_transfers
|
||||
ADD CONSTRAINT rcv_roster_transfers_from_member_id_fkey FOREIGN KEY (from_member_id) REFERENCES test_chat_schema.group_members(group_member_id) ON DELETE CASCADE;
|
||||
|
||||
|
||||
|
||||
ALTER TABLE ONLY test_chat_schema.rcv_roster_transfers
|
||||
ADD CONSTRAINT rcv_roster_transfers_group_id_fkey FOREIGN KEY (group_id) REFERENCES test_chat_schema.groups(group_id) ON DELETE CASCADE;
|
||||
|
||||
|
||||
|
||||
ALTER TABLE ONLY test_chat_schema.received_probes
|
||||
ADD CONSTRAINT received_probes_contact_id_fkey FOREIGN KEY (contact_id) REFERENCES test_chat_schema.contacts(contact_id) ON DELETE CASCADE;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user