From 47becd416dafb293a8a8cb6498eea00cbd94b03a Mon Sep 17 00:00:00 2001 From: Volnei Munhoz Date: Thu, 29 Jan 2026 17:36:40 -0300 Subject: [PATCH] feat: add index on channelId for SelectedCalendar (#27403) Add database index on the channelId column in the SelectedCalendar table to improve lookup performance for watched calendar channels. --- .../migration.sql | 2 ++ packages/prisma/schema.prisma | 1 + 2 files changed, 3 insertions(+) create mode 100644 packages/prisma/migrations/20260130000000_add_selected_calendar_channel_id_index/migration.sql diff --git a/packages/prisma/migrations/20260130000000_add_selected_calendar_channel_id_index/migration.sql b/packages/prisma/migrations/20260130000000_add_selected_calendar_channel_id_index/migration.sql new file mode 100644 index 0000000000..ac2a0340f1 --- /dev/null +++ b/packages/prisma/migrations/20260130000000_add_selected_calendar_channel_id_index/migration.sql @@ -0,0 +1,2 @@ +-- CreateIndex +CREATE INDEX CONCURRENTLY IF NOT EXISTS "SelectedCalendar_channelId_idx" ON "SelectedCalendar"("channelId"); diff --git a/packages/prisma/schema.prisma b/packages/prisma/schema.prisma index ba0b594067..3c270c75ce 100644 --- a/packages/prisma/schema.prisma +++ b/packages/prisma/schema.prisma @@ -1052,6 +1052,7 @@ model SelectedCalendar { @@index([externalId]) @@index([eventTypeId]) @@index([credentialId]) + @@index([channelId]) // Composite indices to optimize calendar-cache queries @@index([integration, googleChannelExpiration, error, watchAttempts, maxAttempts], name: "SelectedCalendar_watch_idx") @@index([integration, googleChannelExpiration, error, unwatchAttempts, maxAttempts], name: "SelectedCalendar_unwatch_idx")