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;