From f52ab4f1b137ff87a02e10136696fa2169b1438b Mon Sep 17 00:00:00 2001 From: "H. Shay" Date: Wed, 24 Aug 2022 20:35:29 -0700 Subject: [PATCH 1/5] drop unused column --- ...ation_services_state_last_txn.sql.postgres | 17 ++++++++ ...ication_services_state_last_txn.sql.sqlite | 40 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 synapse/storage/schema/main/delta/72/04drop_column_application_services_state_last_txn.sql.postgres create mode 100644 synapse/storage/schema/main/delta/72/04drop_column_application_services_state_last_txn.sql.sqlite diff --git a/synapse/storage/schema/main/delta/72/04drop_column_application_services_state_last_txn.sql.postgres b/synapse/storage/schema/main/delta/72/04drop_column_application_services_state_last_txn.sql.postgres new file mode 100644 index 000000000000..13d47de9e69e --- /dev/null +++ b/synapse/storage/schema/main/delta/72/04drop_column_application_services_state_last_txn.sql.postgres @@ -0,0 +1,17 @@ +/* Copyright 2022 The Matrix.org Foundation C.I.C + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +-- Drop unused column application_services_state.last_txn +ALTER table application_services_state DROP COLUMN last_txn; \ No newline at end of file diff --git a/synapse/storage/schema/main/delta/72/04drop_column_application_services_state_last_txn.sql.sqlite b/synapse/storage/schema/main/delta/72/04drop_column_application_services_state_last_txn.sql.sqlite new file mode 100644 index 000000000000..1e4a0a9a5e94 --- /dev/null +++ b/synapse/storage/schema/main/delta/72/04drop_column_application_services_state_last_txn.sql.sqlite @@ -0,0 +1,40 @@ +/* Copyright 2022 The Matrix.org Foundation C.I.C + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +-- Drop unused column application_services_state.last_txn + +CREATE TABLE application_services_state2 ( + as_id TEXT PRIMARY KEY, + state VARCHAR(5), + read_receipt_stream_id INT, + presence_stream_id INT, + to_device_stream_id BIGINT, + device_list_stream_id BIGINT +); + + +INSERT INTO application_services_state2 ( + as_id, + state, + read_receipt_stream_id, + presence_stream_id, + to_device_stream_id, + device_list_stream_id +) +SELECT as_id, state, read_receipt_stream_id, presence_stream_id, to_device_stream_id, device_list_stream_id +FROM application_services_state; + +DROP TABLE application_services_state; +ALTER TABLE application_services_state2 RENAME TO application_services_state; \ No newline at end of file From 86bc3b0633e287a992c23c804f17da9da270cf03 Mon Sep 17 00:00:00 2001 From: "H. Shay" Date: Wed, 24 Aug 2022 20:35:35 -0700 Subject: [PATCH 2/5] newsfragment --- changelog.d/13617.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/13617.misc diff --git a/changelog.d/13617.misc b/changelog.d/13617.misc new file mode 100644 index 000000000000..1a15709aff0b --- /dev/null +++ b/changelog.d/13617.misc @@ -0,0 +1 @@ +Drop unused column `application_services_state.last_txn`. From 092fbba60fd37532a822fa4f785e6ad19832f941 Mon Sep 17 00:00:00 2001 From: "H. Shay" Date: Wed, 24 Aug 2022 20:40:44 -0700 Subject: [PATCH 3/5] fix newsfragment number --- changelog.d/{13617.misc => 13627.misc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog.d/{13617.misc => 13627.misc} (100%) diff --git a/changelog.d/13617.misc b/changelog.d/13627.misc similarity index 100% rename from changelog.d/13617.misc rename to changelog.d/13627.misc From a3a1592532747cbfcd26c99f180ec432b4153764 Mon Sep 17 00:00:00 2001 From: "H. Shay" Date: Thu, 25 Aug 2022 11:28:42 -0700 Subject: [PATCH 4/5] fix int size on column and add index --- ..._column_application_services_state_last_txn.sql.sqlite | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/synapse/storage/schema/main/delta/72/04drop_column_application_services_state_last_txn.sql.sqlite b/synapse/storage/schema/main/delta/72/04drop_column_application_services_state_last_txn.sql.sqlite index 1e4a0a9a5e94..38b4bb169247 100644 --- a/synapse/storage/schema/main/delta/72/04drop_column_application_services_state_last_txn.sql.sqlite +++ b/synapse/storage/schema/main/delta/72/04drop_column_application_services_state_last_txn.sql.sqlite @@ -18,8 +18,8 @@ CREATE TABLE application_services_state2 ( as_id TEXT PRIMARY KEY, state VARCHAR(5), - read_receipt_stream_id INT, - presence_stream_id INT, + read_receipt_stream_id BIGINT, + presence_stream_id BIGINT, to_device_stream_id BIGINT, device_list_stream_id BIGINT ); @@ -37,4 +37,6 @@ SELECT as_id, state, read_receipt_stream_id, presence_stream_id, to_device_strea FROM application_services_state; DROP TABLE application_services_state; -ALTER TABLE application_services_state2 RENAME TO application_services_state; \ No newline at end of file +ALTER TABLE application_services_state2 RENAME TO application_services_state; + +CREATE INDEX IF NOT EXISTS application_services_state_pkey on application_services_state (as_id); \ No newline at end of file From 79ee0be669f83496fffd3d38e33bf7c890ddfba6 Mon Sep 17 00:00:00 2001 From: "H. Shay" Date: Fri, 26 Aug 2022 08:45:36 -0700 Subject: [PATCH 5/5] requested changes --- synapse/storage/schema/__init__.py | 1 + ...drop_column_application_services_state_last_txn.sql.sqlite | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/synapse/storage/schema/__init__.py b/synapse/storage/schema/__init__.py index a9a88c8bfd8b..256f745dc0e8 100644 --- a/synapse/storage/schema/__init__.py +++ b/synapse/storage/schema/__init__.py @@ -75,6 +75,7 @@ Changes in SCHEMA_VERSION = 72: - event_edges.(room_id, is_state) are no longer written to. - Tables related to groups are dropped. + - Unused column application_services_state.last_txn is dropped """ diff --git a/synapse/storage/schema/main/delta/72/04drop_column_application_services_state_last_txn.sql.sqlite b/synapse/storage/schema/main/delta/72/04drop_column_application_services_state_last_txn.sql.sqlite index 38b4bb169247..3be1c88d7261 100644 --- a/synapse/storage/schema/main/delta/72/04drop_column_application_services_state_last_txn.sql.sqlite +++ b/synapse/storage/schema/main/delta/72/04drop_column_application_services_state_last_txn.sql.sqlite @@ -16,7 +16,7 @@ -- Drop unused column application_services_state.last_txn CREATE TABLE application_services_state2 ( - as_id TEXT PRIMARY KEY, + as_id TEXT PRIMARY KEY NOT NULL, state VARCHAR(5), read_receipt_stream_id BIGINT, presence_stream_id BIGINT, @@ -38,5 +38,3 @@ FROM application_services_state; DROP TABLE application_services_state; ALTER TABLE application_services_state2 RENAME TO application_services_state; - -CREATE INDEX IF NOT EXISTS application_services_state_pkey on application_services_state (as_id); \ No newline at end of file