diff --git a/zilencer/migrations/0059_remoterealmauditlog_add_synced_billing_event_type_index.py b/zilencer/migrations/0059_remoterealmauditlog_add_synced_billing_event_type_index.py new file mode 100644 index 0000000000..9cbeceb513 --- /dev/null +++ b/zilencer/migrations/0059_remoterealmauditlog_add_synced_billing_event_type_index.py @@ -0,0 +1,21 @@ +# Generated by Django 4.2.9 on 2024-02-20 12:04 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("zilencer", "0058_remoteinstallationcount_add_mobile_pushes_forwarded_index"), + ] + + operations = [ + migrations.AddIndex( + model_name="remoterealmauditlog", + index=models.Index( + condition=models.Q(("event_type__in", [101, 102, 103, 104, 105, 201, 202, 229])), + fields=["remote_realm_id", "id"], + name="zilencer_remoterealmauditlog_synced_billing_events", + ), + ), + ] diff --git a/zilencer/models.py b/zilencer/models.py index e0fb655efb..5fdb5591eb 100644 --- a/zilencer/models.py +++ b/zilencer/models.py @@ -333,6 +333,11 @@ class RemoteRealmAuditLog(AbstractRealmAuditLog): condition=Q(remote_realm__isnull=True), name="zilencer_remoterealmauditlog_server", ), + models.Index( + fields=["remote_realm_id", "id"], + condition=Q(event_type__in=AbstractRealmAuditLog.SYNCED_BILLING_EVENTS), + name="zilencer_remoterealmauditlog_synced_billing_events", + ), ]