Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
populate-analytics: Delete attachments before realm and flushing cache.
Lauryn Menardcff8013a6a9f
diff --git a/analytics/management/commands/populate_analytics_db.py b/analytics/management/commands/populate_analytics_db.pyindex 5c67b3a7623..28662c0b68e 100644--- a/analytics/management/commands/populate_analytics_db.py+++ b/analytics/management/commands/populate_analytics_db.py@@ -26,7 +26,7 @@ from zerver.lib.stream_subscription import create_stream_subscriptionfrom zerver.lib.streams import get_default_values_for_stream_permission_group_settingsfrom zerver.lib.timestamp import floor_to_dayfrom zerver.lib.upload import upload_message_attachment_from_request-from zerver.models import Client, Realm, RealmAuditLog, Recipient, Stream, UserProfile+from zerver.models import Attachment, Client, Realm, RealmAuditLog, Recipient, Stream, UserProfilefrom zerver.models.groups import NamedUserGroup, SystemGroups, UserGroupMembershipfrom zerver.models.realm_audit_logs import AuditLogEventType@@ -68,6 +68,10 @@ class Command(ZulipBaseCommand):# associated with the "analytics" realm.do_drop_all_analytics_tables()+ # Delete attachment added for summary statistic before deleting+ # the Realm object.+ Attachment.objects.filter(realm__string_id="analytics").delete()+# This also deletes any objects with this realm as a foreign keyRealm.objects.filter(string_id="analytics").delete()