From f63db4f4fd386fdeeb06fc52ffa13cf65927723f Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Tue, 26 May 2020 18:31:30 +0100 Subject: Move sql schema delta files to their new location --- .../main/schema/delta/48/profiles_batch.sql | 36 ++++++++++++++++++++++ .../schema/delta/50/profiles_deactivated_users.sql | 23 ++++++++++++++ .../delta/55/profile_replication_status_index.sql | 17 ++++++++++ .../main/schema/delta/55/room_retention.sql | 33 ++++++++++++++++++++ synapse/storage/schema/delta/48/profiles_batch.sql | 36 ---------------------- .../schema/delta/50/profiles_deactivated_users.sql | 23 -------------- .../delta/55/profile_replication_status_index.sql | 17 ---------- synapse/storage/schema/delta/55/room_retention.sql | 33 -------------------- 8 files changed, 109 insertions(+), 109 deletions(-) create mode 100644 synapse/storage/data_stores/main/schema/delta/48/profiles_batch.sql create mode 100644 synapse/storage/data_stores/main/schema/delta/50/profiles_deactivated_users.sql create mode 100644 synapse/storage/data_stores/main/schema/delta/55/profile_replication_status_index.sql create mode 100644 synapse/storage/data_stores/main/schema/delta/55/room_retention.sql delete mode 100644 synapse/storage/schema/delta/48/profiles_batch.sql delete mode 100644 synapse/storage/schema/delta/50/profiles_deactivated_users.sql delete mode 100644 synapse/storage/schema/delta/55/profile_replication_status_index.sql delete mode 100644 synapse/storage/schema/delta/55/room_retention.sql diff --git a/synapse/storage/data_stores/main/schema/delta/48/profiles_batch.sql b/synapse/storage/data_stores/main/schema/delta/48/profiles_batch.sql new file mode 100644 index 0000000000..e744c02fe8 --- /dev/null +++ b/synapse/storage/data_stores/main/schema/delta/48/profiles_batch.sql @@ -0,0 +1,36 @@ +/* Copyright 2018 New Vector Ltd + * + * 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. + */ + +/* + * Add a batch number to track changes to profiles and the + * order they're made in so we can replicate user profiles + * to other hosts as they change + */ +ALTER TABLE profiles ADD COLUMN batch BIGINT DEFAULT NULL; + +/* + * Index on the batch number so we can get profiles + * by their batch + */ +CREATE INDEX profiles_batch_idx ON profiles(batch); + +/* + * A table to track what batch of user profiles has been + * synced to what profile replication target. + */ +CREATE TABLE profile_replication_status ( + host TEXT NOT NULL, + last_synced_batch BIGINT NOT NULL +); diff --git a/synapse/storage/data_stores/main/schema/delta/50/profiles_deactivated_users.sql b/synapse/storage/data_stores/main/schema/delta/50/profiles_deactivated_users.sql new file mode 100644 index 0000000000..c8893ecbe8 --- /dev/null +++ b/synapse/storage/data_stores/main/schema/delta/50/profiles_deactivated_users.sql @@ -0,0 +1,23 @@ +/* Copyright 2018 New Vector Ltd + * + * 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. + */ + +/* + * A flag saying whether the user owning the profile has been deactivated + * This really belongs on the users table, not here, but the users table + * stores users by their full user_id and profiles stores them by localpart, + * so we can't easily join between the two tables. Plus, the batch number + * realy ought to represent data in this table that has changed. + */ +ALTER TABLE profiles ADD COLUMN active SMALLINT DEFAULT 1 NOT NULL; diff --git a/synapse/storage/data_stores/main/schema/delta/55/profile_replication_status_index.sql b/synapse/storage/data_stores/main/schema/delta/55/profile_replication_status_index.sql new file mode 100644 index 0000000000..18a0f7e10c --- /dev/null +++ b/synapse/storage/data_stores/main/schema/delta/55/profile_replication_status_index.sql @@ -0,0 +1,17 @@ +/* Copyright 2019 New Vector Ltd + * + * 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. + */ + +INSERT INTO background_updates (update_name, progress_json) VALUES + ('profile_replication_status_host_index', '{}'); diff --git a/synapse/storage/data_stores/main/schema/delta/55/room_retention.sql b/synapse/storage/data_stores/main/schema/delta/55/room_retention.sql new file mode 100644 index 0000000000..ee6cdf7a14 --- /dev/null +++ b/synapse/storage/data_stores/main/schema/delta/55/room_retention.sql @@ -0,0 +1,33 @@ +/* Copyright 2019 New Vector Ltd + * + * 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. + */ + +-- Tracks the retention policy of a room. +-- A NULL max_lifetime or min_lifetime means that the matching property is not defined in +-- the room's retention policy state event. +-- If a room doesn't have a retention policy state event in its state, both max_lifetime +-- and min_lifetime are NULL. +CREATE TABLE IF NOT EXISTS room_retention( + room_id TEXT, + event_id TEXT, + min_lifetime BIGINT, + max_lifetime BIGINT, + + PRIMARY KEY(room_id, event_id) +); + +CREATE INDEX room_retention_max_lifetime_idx on room_retention(max_lifetime); + +INSERT INTO background_updates (update_name, progress_json) VALUES + ('insert_room_retention', '{}'); diff --git a/synapse/storage/schema/delta/48/profiles_batch.sql b/synapse/storage/schema/delta/48/profiles_batch.sql deleted file mode 100644 index e744c02fe8..0000000000 --- a/synapse/storage/schema/delta/48/profiles_batch.sql +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2018 New Vector Ltd - * - * 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. - */ - -/* - * Add a batch number to track changes to profiles and the - * order they're made in so we can replicate user profiles - * to other hosts as they change - */ -ALTER TABLE profiles ADD COLUMN batch BIGINT DEFAULT NULL; - -/* - * Index on the batch number so we can get profiles - * by their batch - */ -CREATE INDEX profiles_batch_idx ON profiles(batch); - -/* - * A table to track what batch of user profiles has been - * synced to what profile replication target. - */ -CREATE TABLE profile_replication_status ( - host TEXT NOT NULL, - last_synced_batch BIGINT NOT NULL -); diff --git a/synapse/storage/schema/delta/50/profiles_deactivated_users.sql b/synapse/storage/schema/delta/50/profiles_deactivated_users.sql deleted file mode 100644 index c8893ecbe8..0000000000 --- a/synapse/storage/schema/delta/50/profiles_deactivated_users.sql +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2018 New Vector Ltd - * - * 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. - */ - -/* - * A flag saying whether the user owning the profile has been deactivated - * This really belongs on the users table, not here, but the users table - * stores users by their full user_id and profiles stores them by localpart, - * so we can't easily join between the two tables. Plus, the batch number - * realy ought to represent data in this table that has changed. - */ -ALTER TABLE profiles ADD COLUMN active SMALLINT DEFAULT 1 NOT NULL; diff --git a/synapse/storage/schema/delta/55/profile_replication_status_index.sql b/synapse/storage/schema/delta/55/profile_replication_status_index.sql deleted file mode 100644 index 18a0f7e10c..0000000000 --- a/synapse/storage/schema/delta/55/profile_replication_status_index.sql +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2019 New Vector Ltd - * - * 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. - */ - -INSERT INTO background_updates (update_name, progress_json) VALUES - ('profile_replication_status_host_index', '{}'); diff --git a/synapse/storage/schema/delta/55/room_retention.sql b/synapse/storage/schema/delta/55/room_retention.sql deleted file mode 100644 index ee6cdf7a14..0000000000 --- a/synapse/storage/schema/delta/55/room_retention.sql +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2019 New Vector Ltd - * - * 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. - */ - --- Tracks the retention policy of a room. --- A NULL max_lifetime or min_lifetime means that the matching property is not defined in --- the room's retention policy state event. --- If a room doesn't have a retention policy state event in its state, both max_lifetime --- and min_lifetime are NULL. -CREATE TABLE IF NOT EXISTS room_retention( - room_id TEXT, - event_id TEXT, - min_lifetime BIGINT, - max_lifetime BIGINT, - - PRIMARY KEY(room_id, event_id) -); - -CREATE INDEX room_retention_max_lifetime_idx on room_retention(max_lifetime); - -INSERT INTO background_updates (update_name, progress_json) VALUES - ('insert_room_retention', '{}'); -- cgit 1.5.1