From c073e5adb45a24f1e825ea086e00e46f304ff27e Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Mon, 4 Nov 2024 23:06:44 -0800 Subject: [PATCH] migrations: Avoid following realm foreign key unnecessarily. I encountered at least one scenario where the previous logic would fail due to migration state confusion, but this could also be a bit faster. --- zerver/migrations/0617_remove_prefix_from_archived_streams.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zerver/migrations/0617_remove_prefix_from_archived_streams.py b/zerver/migrations/0617_remove_prefix_from_archived_streams.py index 4c7898da0a..0083516fbd 100644 --- a/zerver/migrations/0617_remove_prefix_from_archived_streams.py +++ b/zerver/migrations/0617_remove_prefix_from_archived_streams.py @@ -32,7 +32,9 @@ def remove_prefix_from_archived_streams( continue # Check if there's an active stream or another archived stream with the new name - if not Stream.objects.filter(realm=archived_stream.realm, name__iexact=new_name).exists(): + if not Stream.objects.filter( + realm_id=archived_stream.realm_id, name__iexact=new_name + ).exists(): archived_stream.name = new_name archived_stream.save(update_fields=["name"])