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[]
|
tickets Ticket[]
|
||||||
|
|
||||||
@@unique([categoryId, name])
|
@@unique([categoryId, name])
|
||||||
|
@@index([categoryId])
|
||||||
}
|
}
|
||||||
|
|
||||||
model Item {
|
model Item {
|
||||||
@@ -67,6 +68,7 @@ model Item {
|
|||||||
tickets Ticket[]
|
tickets Ticket[]
|
||||||
|
|
||||||
@@unique([typeId, name])
|
@@unique([typeId, name])
|
||||||
|
@@index([typeId])
|
||||||
}
|
}
|
||||||
|
|
||||||
model Ticket {
|
model Ticket {
|
||||||
@@ -141,6 +143,7 @@ model Attachment {
|
|||||||
|
|
||||||
@@index([ticketId])
|
@@index([ticketId])
|
||||||
@@index([commentId])
|
@@index([commentId])
|
||||||
|
@@index([uploadedById])
|
||||||
}
|
}
|
||||||
|
|
||||||
model Webhook {
|
model Webhook {
|
||||||
@@ -195,4 +198,6 @@ model AuditLog {
|
|||||||
|
|
||||||
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
|
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
|
||||||
user User @relation(fields: [userId], references: [id])
|
user User @relation(fields: [userId], references: [id])
|
||||||
|
|
||||||
|
@@index([ticketId, createdAt])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user