diff --git a/synapse/storage/schema/main/delta/88/02_state_groups_epochs.sql b/synapse/storage/schema/main/delta/88/02_state_groups_epochs.sql new file mode 100644 index 0000000000..afc36a65c3 --- /dev/null +++ b/synapse/storage/schema/main/delta/88/02_state_groups_epochs.sql @@ -0,0 +1,28 @@ +-- +-- This file is licensed under the Affero General Public License (AGPL) version 3. +-- +-- Copyright (C) 2024 New Vector, Ltd +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU Affero General Public License as +-- published by the Free Software Foundation, either version 3 of the +-- License, or (at your option) any later version. +-- +-- See the GNU Affero General Public License for more details: +-- . + + +CREATE TABLE IF NOT EXISTS state_epoch ( + Lock CHAR(1) NOT NULL DEFAULT 'X' UNIQUE, -- Makes sure this table only has one row. + state_epoch BIGINT NOT NULL, + updated_ts BIGINT NOT NULL, + CHECK (Lock='X') +); + +CREATE TABLE IF NOT EXISTS state_groups_pending_deletion ( + state_group BIGINT NOT NULL, + state_epoch BIGINT NOT NULL, + PRIMARY KEY (state_group, state_epoch) +); + +CREATE INDEX state_groups_pending_deletion_epoch ON state_groups_pending_deletion(state_epoch);