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.
This commit is contained in:
Tim Abbott 2024-11-04 23:06:44 -08:00
parent 5571fb6a3e
commit c073e5adb4
1 changed files with 3 additions and 1 deletions

View File

@ -32,7 +32,9 @@ def remove_prefix_from_archived_streams(
continue continue
# Check if there's an active stream or another archived stream with the new name # 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.name = new_name
archived_stream.save(update_fields=["name"]) archived_stream.save(update_fields=["name"])