Skip to content

Commit f5473da

Browse files
feat: add indices to speed up filtering and search
1 parent 37c09f3 commit f5473da

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

openedx_authz/migrations/0008_roleassignmentaudit.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ class Migration(migrations.Migration):
6868
"verbose_name": "Role Assignment Audit",
6969
"verbose_name_plural": "Role Assignment Audits",
7070
"ordering": ["-timestamp"],
71+
"indexes": [
72+
models.Index(fields=["subject"], name="role_audit_subject_idx"),
73+
models.Index(fields=["scope"], name="role_audit_scope_idx"),
74+
],
7175
},
7276
),
7377
]

openedx_authz/models/core.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ class Meta:
297297
verbose_name = "Role Assignment Audit"
298298
verbose_name_plural = "Role Assignment Audits"
299299
ordering = ["-timestamp"]
300+
indexes = [
301+
models.Index(fields=["subject"], name="role_audit_subject_idx"),
302+
models.Index(fields=["scope"], name="role_audit_scope_idx"),
303+
]
300304

301305
@property
302306
def subject_display(self) -> str:

0 commit comments

Comments
 (0)