Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
migrations: Remove the possibly-duplicated emoji re-uploading.
Alex Vandiver35e27aef4a3c
diff --git a/tools/semgrep.yml b/tools/semgrep.ymlindex 44605cfe5f0..498d0695c00 100644--- a/tools/semgrep.yml+++ b/tools/semgrep.yml@@ -39,7 +39,6 @@ rules:- zerver/migrations/0206_stream_rendered_description.py- zerver/migrations/0209_user_profile_no_empty_password.py- zerver/migrations/0260_missed_message_addresses_from_redis_to_db.py- - zerver/migrations/0376_set_realmemoji_author_and_reupload_realmemoji.py- zerver/migrations/0387_reupload_realmemoji_again.py- pgroonga/migrations/0002_html_escape_subject.pydiff --git a/zerver/migrations/0376_set_realmemoji_author_and_reupload_realmemoji.py b/zerver/migrations/0376_set_realmemoji_author_and_reupload_realmemoji.pyindex e0cc61f3fc3..63f86a70d55 100644--- a/zerver/migrations/0376_set_realmemoji_author_and_reupload_realmemoji.py+++ b/zerver/migrations/0376_set_realmemoji_author_and_reupload_realmemoji.py@@ -1,10 +1,7 @@-from django.conf import settingsfrom django.db import migrationsfrom django.db.backends.postgresql.schema import DatabaseSchemaEditorfrom django.db.migrations.state import StateApps-from zerver.lib.queue import queue_json_publish-def set_emoji_author(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:"""@@ -13,7 +10,6 @@ def set_emoji_author(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> No"""RealmEmoji = apps.get_model("zerver", "RealmEmoji")- Realm = apps.get_model("zerver", "Realm")UserProfile = apps.get_model("zerver", "UserProfile")ROLE_REALM_OWNER = 100@@ -32,18 +28,12 @@ def set_emoji_author(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> NoRealmEmoji.objects.bulk_update(realm_emoji_to_update, ["author_id"])- if settings.TEST_SUITE:- # There are no custom emoji in the test suite data set, and- # the below code won't work because RabbitMQ isn't enabled for- # the test suite.- return-- for realm_id in Realm.objects.order_by("id").values_list("id", flat=True):- event = {- "type": "reupload_realm_emoji",- "realm_id": realm_id,- }- queue_json_publish("deferred_work", event)+ # Previously, this also pushed `reupload_realm_emoji` events onto+ # the `deferred_work` queue; however,+ # https://github.com/zulip/zulip/issues/21608 made those possibly+ # run too early, and that work was repeated in migration 0387 to+ # ensure it ran. As such, the work has been removed from this+ # migration, so it does not unnecessarily run twice.class Migration(migrations.Migration):diff --git a/zerver/migrations/0387_reupload_realmemoji_again.py b/zerver/migrations/0387_reupload_realmemoji_again.pyindex 9d49a1663be..afd830a5ffe 100644--- a/zerver/migrations/0387_reupload_realmemoji_again.py+++ b/zerver/migrations/0387_reupload_realmemoji_again.py@@ -12,12 +12,14 @@ def reupload_realm_emoji(apps: StateApps, schema_editor: DatabaseSchemaEditor) -started up by puppet during the deployment before migrations wererun on Zulip 5.0.- This means that the deferred_work events produced by migration- 0376 might have been processed and discarded without effect.-- Since it's harmless to reupload a custom emoji a second time, we- fix this issue for the slice of servers that have already- installed 5.0 by repeating that part of the migration.+ This means that the deferred_work events originally produced by+ migration 0376 might have been processed and discarded without+ effect.++ That code has been removed from the 0376 migration, and we run it+ here, after the upgrade code has been fixed; servers which already+ processed that migration might at worst do this work twice, which+ is harmless aside from being a small waste of resources."""Realm = apps.get_model("zerver", "Realm")