chore: add indexes for user delete (#24740)

* chore: Adding indexes for user delete cascade

* Add comments to indicate a partial index has been added on a field

---------

Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
This commit is contained in:
Alex van Andel
2025-10-28 22:28:40 +00:00
committed by GitHub
co-authored by Morgan
parent 0223027958
commit 29a3892669
2 changed files with 19 additions and 0 deletions
@@ -0,0 +1,11 @@
CREATE INDEX "Booking_reassignById_idx" ON "Booking"("reassignById")
WHERE "reassignById" IS NOT NULL;
CREATE INDEX "EventType_instantMeetingScheduleId_idx" ON "EventType"("instantMeetingScheduleId")
WHERE "instantMeetingScheduleId" IS NOT NULL;
CREATE INDEX "CreditExpenseLog_bookingUid_idx" ON "CreditExpenseLog"("bookingUid")
WHERE "bookingUid" IS NOT NULL;
CREATE INDEX "WebhookScheduledTriggers_bookingId_idx" ON "WebhookScheduledTriggers"("bookingId")
WHERE "bookingId" IS NOT NULL;
+8
View File
@@ -244,6 +244,8 @@ model EventType {
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
// @@partial_index([instantMeetingScheduleId])
@@unique([userId, slug])
@@unique([teamId, slug])
@@unique([userId, parentId])
@@ -640,6 +642,8 @@ model CreditExpenseLog {
callDuration Int?
creditFor CreditUsageType?
externalRef String? @unique
// @@partial_index([bookingUid])
}
enum CreditType {
@@ -852,6 +856,8 @@ model Booking {
expenseLogs CreditExpenseLog[]
report BookingReport?
// @@partial_index([reassignById])
@@index([eventTypeId])
@@index([userId])
@@index([destinationCalendarId])
@@ -1575,6 +1581,8 @@ model WebhookScheduledTriggers {
webhook Webhook? @relation(fields: [webhookId], references: [id], onDelete: Cascade)
bookingId Int?
booking Booking? @relation(fields: [bookingId], references: [id], onDelete: Cascade)
// @@partial_index([bookingId])
}
enum WorkflowTemplates {