From 5188cf3d8e35e93bea228d5ff963293105781a09 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 13 Aug 2024 14:39:30 -0700 Subject: [PATCH] migrations: Remove RunPython block from initial migration. Since it's the initial migration, this can't have any useful effect. I'm pretty sure the backstory is we did a manual squash of migrations during the process of open-sourcing Zulip, and incorrectly didn't remove this code. --- zerver/migrations/0001_initial.py | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/zerver/migrations/0001_initial.py b/zerver/migrations/0001_initial.py index c5145b64b3..8026ac428f 100644 --- a/zerver/migrations/0001_initial.py +++ b/zerver/migrations/0001_initial.py @@ -8,33 +8,11 @@ from django.conf import settings from django.contrib.postgres.indexes import GinIndex from django.contrib.postgres.search import SearchVectorField from django.db import migrations, models -from django.db.backends.base.schema import BaseDatabaseSchemaEditor -from django.db.migrations.state import StateApps from django.db.models.functions import Upper from zerver.models.streams import generate_email_token_for_stream -def migrate_existing_attachment_data( - apps: StateApps, schema_editor: BaseDatabaseSchemaEditor -) -> None: - Attachment = apps.get_model("zerver", "Attachment") - Recipient = apps.get_model("zerver", "Recipient") - Stream = apps.get_model("zerver", "Stream") - - attachments = Attachment.objects.all() - for entry in attachments: - owner = entry.owner - entry.realm = owner.realm - for message in entry.messages.all(): - if owner == message.sender and message.recipient.type == Recipient.STREAM: - stream = Stream.objects.get(id=message.recipient.type_id) - is_realm_public = not stream.realm.is_zephyr_mirror_realm and not stream.invite_only - entry.is_realm_public = entry.is_realm_public or is_realm_public - - entry.save() - - class Migration(migrations.Migration): initial = True @@ -896,10 +874,6 @@ CREATE TRIGGER zerver_message_update_search_tsvector_async to="zerver.Realm", ), ), - migrations.RunPython( - code=migrate_existing_attachment_data, - elidable=True, - ), migrations.AddField( model_name="subscription", name="pin_to_top",