diff --git a/zilencer/migrations/0045_remoterealmauditlog_zilencer_remoterealmauditlog_server_realm_and_more.py b/zilencer/migrations/0045_remoterealmauditlog_zilencer_remoterealmauditlog_server_realm_and_more.py new file mode 100644 index 0000000000..e4172748ea --- /dev/null +++ b/zilencer/migrations/0045_remoterealmauditlog_zilencer_remoterealmauditlog_server_realm_and_more.py @@ -0,0 +1,44 @@ +# Generated by Django 4.2.7 on 2023-12-05 19:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("zilencer", "0044_remoterealmbillinguser"), + ] + + operations = [ + migrations.AddIndex( + model_name="remoterealmauditlog", + index=models.Index( + condition=models.Q(("remote_realm__isnull", True)), + fields=["server", "realm_id"], + name="zilencer_remoterealmauditlog_server_realm", + ), + ), + migrations.AddIndex( + model_name="remoterealmauditlog", + index=models.Index( + condition=models.Q(("remote_realm__isnull", True)), + fields=["server"], + name="zilencer_remoterealmauditlog_server", + ), + ), + migrations.AddIndex( + model_name="remoterealmcount", + index=models.Index( + condition=models.Q(("remote_realm__isnull", True)), + fields=["server", "realm_id"], + name="zilencer_remoterealmcount_server_realm", + ), + ), + migrations.AddIndex( + model_name="remoterealmcount", + index=models.Index( + condition=models.Q(("remote_realm__isnull", True)), + fields=["server"], + name="zilencer_remoterealmcount_server", + ), + ), + ] diff --git a/zilencer/models.py b/zilencer/models.py index 63de4ad625..e98216afab 100644 --- a/zilencer/models.py +++ b/zilencer/models.py @@ -212,6 +212,16 @@ class RemoteRealmAuditLog(AbstractRealmAuditLog): fields=["server", "realm_id", "remote_id"], name="zilencer_remoterealmauditlog_server_realm_remote", ), + models.Index( + fields=["server", "realm_id"], + condition=Q(remote_realm__isnull=True), + name="zilencer_remoterealmauditlog_server_realm", + ), + models.Index( + fields=["server"], + condition=Q(remote_realm__isnull=True), + name="zilencer_remoterealmauditlog_server", + ), ] @@ -296,6 +306,16 @@ class RemoteRealmCount(BaseRemoteCount): fields=["property", "end_time"], name="zilencer_remoterealmcount_property_end_time_506a0b38_idx", ), + models.Index( + fields=["server", "realm_id"], + condition=Q(remote_realm__isnull=True), + name="zilencer_remoterealmcount_server_realm", + ), + models.Index( + fields=["server"], + condition=Q(remote_realm__isnull=True), + name="zilencer_remoterealmcount_server", + ), ] @override