mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
migrations: Repeat part of migration 0376.
The blockquote explains the motivation for this change in detail. Fixes #21608.
This commit is contained in:
committed by
Alex Vandiver
parent
c79849dab6
commit
85e531e377
@@ -40,6 +40,7 @@ rules:
|
||||
- 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.py
|
||||
|
||||
- id: logging-format
|
||||
|
||||
46
zerver/migrations/0387_reupload_realmemoji_again.py
Normal file
46
zerver/migrations/0387_reupload_realmemoji_again.py
Normal file
@@ -0,0 +1,46 @@
|
||||
from django.conf import settings
|
||||
from django.db import migrations
|
||||
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
|
||||
from django.db.migrations.state import StateApps
|
||||
|
||||
from zerver.lib.queue import queue_json_publish
|
||||
|
||||
|
||||
def reupload_realm_emoji(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
|
||||
"""As detailed in https://github.com/zulip/zulip/issues/21608, it is
|
||||
possible for the deferred_work queue from Zulip 4.x to have been
|
||||
started up by puppet during the deployment before migrations were
|
||||
run 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.
|
||||
"""
|
||||
|
||||
Realm = apps.get_model("zerver", "Realm")
|
||||
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)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("zerver", "0386_fix_attachment_caches"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(reupload_realm_emoji, reverse_code=migrations.RunPython.noop),
|
||||
]
|
||||
Reference in New Issue
Block a user