From 70fd93a7f68e830252226eef60205a693798f3d2 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Fri, 31 Mar 2023 10:47:42 +0100 Subject: [PATCH] Move DROP INDEX to after ALTER .. SET NOT NULL --- .../74/03thread_notifications_not_null.sql.postgres | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/synapse/storage/schema/main/delta/74/03thread_notifications_not_null.sql.postgres b/synapse/storage/schema/main/delta/74/03thread_notifications_not_null.sql.postgres index 5f68667425..b150c744fa 100644 --- a/synapse/storage/schema/main/delta/74/03thread_notifications_not_null.sql.postgres +++ b/synapse/storage/schema/main/delta/74/03thread_notifications_not_null.sql.postgres @@ -13,11 +13,13 @@ * limitations under the License. */ --- Drop the indexes used to find null thread_ids. -DROP INDEX IF EXISTS event_push_actions_thread_id_null; -DROP INDEX IF EXISTS event_push_summary_thread_id_null; - -- The thread_id columns can now be made non-nullable. ALTER TABLE event_push_actions_staging ALTER COLUMN thread_id SET NOT NULL; ALTER TABLE event_push_actions ALTER COLUMN thread_id SET NOT NULL; ALTER TABLE event_push_summary ALTER COLUMN thread_id SET NOT NULL; + +-- Drop the indexes used to find null thread_ids. +-- Only do this *after* the ALTER because the indices may be useful for validating +-- the NOT NULL constraint. +DROP INDEX IF EXISTS event_push_actions_thread_id_null; +DROP INDEX IF EXISTS event_push_summary_thread_id_null;