fix: align private and channel update semantics
(cherry picked from commit c65f76f56278f74082c4fa792ed49104d5d33c38)
This commit is contained in:
parent
dce7b92772
commit
d84fa6e126
36 changed files with 1765 additions and 382 deletions
35
deploy/migrations/0068_content_unread_and_blocks.down.sql
Normal file
35
deploy/migrations/0068_content_unread_and_blocks.down.sql
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
DROP TABLE IF EXISTS contact_blocks;
|
||||
|
||||
ALTER TABLE user_update_events
|
||||
DROP CONSTRAINT IF EXISTS user_update_events_type_check;
|
||||
|
||||
ALTER TABLE user_update_events
|
||||
ADD CONSTRAINT user_update_events_type_check CHECK (
|
||||
event_type IN (
|
||||
'new_message',
|
||||
'read_history_inbox',
|
||||
'read_history_outbox',
|
||||
'edit_message',
|
||||
'message_reactions',
|
||||
'contacts_reset',
|
||||
'dialog_pinned',
|
||||
'pinned_dialogs',
|
||||
'dialog_unread_mark',
|
||||
'peer_settings',
|
||||
'delete_messages',
|
||||
'dialog_filter',
|
||||
'dialog_filter_order',
|
||||
'dialog_filters',
|
||||
'folder_peers',
|
||||
'channel_available_messages',
|
||||
'channel_view_forum_as_messages',
|
||||
'noop'
|
||||
)
|
||||
);
|
||||
|
||||
ALTER TABLE channel_unread_mentions
|
||||
DROP COLUMN IF EXISTS media_unread;
|
||||
|
||||
ALTER TABLE message_boxes
|
||||
DROP COLUMN IF EXISTS reaction_unread,
|
||||
DROP COLUMN IF EXISTS media_unread;
|
||||
58
deploy/migrations/0068_content_unread_and_blocks.up.sql
Normal file
58
deploy/migrations/0068_content_unread_and_blocks.up.sql
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
ALTER TABLE message_boxes
|
||||
ADD COLUMN IF NOT EXISTS media_unread BOOLEAN NOT NULL DEFAULT false,
|
||||
ADD COLUMN IF NOT EXISTS reaction_unread BOOLEAN NOT NULL DEFAULT false;
|
||||
|
||||
ALTER TABLE channel_unread_mentions
|
||||
ADD COLUMN IF NOT EXISTS media_unread BOOLEAN NOT NULL DEFAULT false;
|
||||
|
||||
ALTER TABLE user_update_events
|
||||
DROP CONSTRAINT IF EXISTS user_update_events_type_check;
|
||||
|
||||
ALTER TABLE user_update_events
|
||||
ADD CONSTRAINT user_update_events_type_check CHECK (
|
||||
event_type IN (
|
||||
'new_message',
|
||||
'read_history_inbox',
|
||||
'read_history_outbox',
|
||||
'read_message_contents',
|
||||
'edit_message',
|
||||
'message_reactions',
|
||||
'contacts_reset',
|
||||
'dialog_pinned',
|
||||
'pinned_dialogs',
|
||||
'dialog_unread_mark',
|
||||
'peer_settings',
|
||||
'delete_messages',
|
||||
'dialog_filter',
|
||||
'dialog_filter_order',
|
||||
'dialog_filters',
|
||||
'folder_peers',
|
||||
'channel_available_messages',
|
||||
'channel_view_forum_as_messages',
|
||||
'noop'
|
||||
)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS contact_blocks (
|
||||
owner_user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
blocked_user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
date INT NOT NULL DEFAULT 0,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (owner_user_id, blocked_user_id)
|
||||
) PARTITION BY HASH (owner_user_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS contact_blocks_owner_date_idx
|
||||
ON contact_blocks (owner_user_id, date DESC, blocked_user_id DESC);
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
i int;
|
||||
BEGIN
|
||||
FOR i IN 0..63 LOOP
|
||||
EXECUTE format(
|
||||
'CREATE TABLE IF NOT EXISTS contact_blocks_p%s PARTITION OF contact_blocks FOR VALUES WITH (MODULUS 64, REMAINDER %s)',
|
||||
lpad(i::text, 2, '0'),
|
||||
i
|
||||
);
|
||||
END LOOP;
|
||||
END $$;
|
||||
Loading…
Add table
Add a link
Reference in a new issue