Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

migrations: Remove RunPython block from initial migration.

Tim Abbott5188cf3d8e35
diff --git a/zerver/migrations/0001_initial.py b/zerver/migrations/0001_initial.py
index c5145b64b36..8026ac428fe 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",