Skip to content

Commit

Permalink
audit-logs: Add index to RealmAuditLog for realm and event type.
Browse files Browse the repository at this point in the history
Adds an index on RealmAuditLog for the realm, event_type, and id
in order to improve database queries on these audit logs.
  • Loading branch information
laurynmm committed Apr 17, 2024
1 parent f31579a commit e375faf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions zerver/migrations/0510_add_realmauditlog_realm_event_type_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.12 on 2024-04-17 10:33

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("zerver", "0509_fix_emoji_metadata"),
]

operations = [
migrations.AddIndex(
model_name="realmauditlog",
index=models.Index(
fields=["realm", "event_type", "id"], name="zerver_realmauditlog_realm_event_type"
),
),
]
6 changes: 5 additions & 1 deletion zerver/models/realm_audit_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ class Meta:
AbstractRealmAuditLog.SUBSCRIPTION_DEACTIVATED,
]
),
)
),
models.Index(
name="zerver_realmauditlog_realm_event_type",
fields=["realm", "event_type", "id"],
),
]

@override
Expand Down

0 comments on commit e375faf

Please sign in to comment.