Add missing database indexes for FK lookups and audit queries

Type(categoryId), Item(typeId), Attachment(uploadedById), and
AuditLog(ticketId, createdAt) were missing indexes for their
primary query patterns.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-21 20:25:40 -04:00
parent 5acc252921
commit 28274bf7bd
+5
View File
@@ -57,6 +57,7 @@ model Type {
tickets Ticket[]
@@unique([categoryId, name])
@@index([categoryId])
}
model Item {
@@ -67,6 +68,7 @@ model Item {
tickets Ticket[]
@@unique([typeId, name])
@@index([typeId])
}
model Ticket {
@@ -141,6 +143,7 @@ model Attachment {
@@index([ticketId])
@@index([commentId])
@@index([uploadedById])
}
model Webhook {
@@ -195,4 +198,6 @@ model AuditLog {
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id])
@@index([ticketId, createdAt])
}