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:
@@ -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])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user