feat(src/tickets): add database indexes for performance

Improve query speed on Ticket, TicketComment, and TicketPriority by indexing fields used in frequent filters and ordering.
This commit is contained in:
sankalp committed 2026-06-30 10:42:10 +05:45
1 parent fb0aab3da9
commit 72f0474f45
1 file changed
+10
+10
View File
@@ -20,6 +20,9 @@ class TicketPriority(models.Model):
db_table = "ticket_priorities"
verbose_name = "Ticket Priority"
verbose_name_plural = "Ticket Priorities"
indexes = [
models.Index(fields=["name"]),
]
def __str__(self):
return self.name
@@ -103,6 +106,12 @@ class Ticket(models.Model):
models.Index(fields=["due_date"]),
models.Index(fields=["priority"]),
models.Index(fields=["created_by"]),
models.Index(fields=["epic"]),
models.Index(fields=["name"]),
models.Index(fields=["start_date"]),
models.Index(fields=["project", "name"]),
models.Index(fields=["project", "start_date", "due_date"]),
models.Index(fields=["due_date", "status"]),
]
def __str__(self):
@@ -190,6 +199,7 @@ class TicketComment(models.Model):
verbose_name_plural = "Ticket Comments"
indexes = [
models.Index(fields=["ticket", "created_at"]),
models.Index(fields=["user"]),
]
def __str__(self):