Update descriptions

This commit is contained in:
Eric Eastwood 2024-08-12 15:43:06 -05:00
parent 0af3b4822c
commit 552f8f496d

View file

@ -11,11 +11,15 @@
-- See the GNU Affero General Public License for more details:
-- <https://www.gnu.org/licenses/agpl-3.0.html>.
-- We store the join memberships in a separate table from
-- `sliding_sync_membership_snapshots` because we need up-to-date information for joined
-- rooms and it can be shared across everyone who is joined.
-- A table for storing room meta data (current state relevant to sliding sync) that the
-- local server is still participating in (someone local is joined to the room).
--
-- This table is kept in sync with `current_state_events`
-- We store the joined rooms in separate table from `sliding_sync_membership_snapshots`
-- because we need up-to-date information for joined rooms and it can be shared across
-- everyone who is joined.
--
-- This table is kept in sync with `current_state_events` which means if the server is
-- no longer participating in a room, the row will be deleted.
CREATE TABLE IF NOT EXISTS sliding_sync_joined_rooms(
room_id TEXT NOT NULL REFERENCES rooms(room_id),
-- The `stream_ordering` of the latest event in the room
@ -28,11 +32,21 @@ CREATE TABLE IF NOT EXISTS sliding_sync_joined_rooms(
room_name TEXT,
-- `m.room.encryption` -> `content.algorithm` (current state)
is_encrypted BOOLEAN DEFAULT 0 NOT NULL,
-- FIXME: Maybe we want to add `tombstone_successor_room_id` here to help with `include_old_rooms`
-- (tracked by https://github.com/element-hq/synapse/issues/17540)
PRIMARY KEY (room_id)
);
-- Store a snapshot of some state relevant for sliding sync for a user's room
-- membership. Only stores the latest membership event for a given user in a room.
-- A table for storing a snapshot of room meta data (historical current state relevant
-- for sliding sync) at the time of a local user's membership. Only has rows for the
-- latest membership event for a given local user in a room which matches
-- `local_current_membership` .
--
-- We store all memberships including joins. This makes it easy to reference this table
-- to find all membership for a given user and shares the same semantics as
-- `local_current_membership`. And we get to avoid some table maintenance; if we only
-- stored non-joins, we would have to delete the row for the user when the user joins
-- the room.
--
-- We don't include `bump_stamp` here because we can just use the `stream_ordering` from
-- the membership event itself as the `bump_stamp`.
@ -57,5 +71,7 @@ CREATE TABLE IF NOT EXISTS sliding_sync_membership_snapshots(
PRIMARY KEY (room_id, user_id)
);
-- So we can fetch all rooms for a given user
CREATE UNIQUE INDEX IF NOT EXISTS sliding_sync_membership_snapshots_user_id ON sliding_sync_membership_snapshots(user_id);
-- So we can sort by `stream_ordering
CREATE UNIQUE INDEX IF NOT EXISTS sliding_sync_membership_snapshots_event_stream_ordering ON sliding_sync_membership_snapshots(event_stream_ordering);
CREATE UNIQUE INDEX IF NOT EXISTS sliding_sync_membership_snapshots_membership_event_id ON sliding_sync_membership_snapshots(membership_event_id);