Skip to content

Commit 5fd11f9

Browse files
committed
Set default value for CalendarCache.updatedAt
Added a default value of NOW() for the updatedAt column in the CalendarCache table to ensure existing and future rows have a valid timestamp. Updated the Prisma schema to reflect this change and provide compatibility for legacy data and raw inserts.
1 parent e1df0a5 commit 5fd11f9

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

packages/prisma/migrations/20250715160635_add_calendar_cache_updated_at/migration.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
66
*/
77
-- AlterTable
8-
ALTER TABLE "CalendarCache" ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL;
8+
-- Add the column with a default value to safely handle existing rows
9+
ALTER TABLE "CalendarCache" ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT NOW();

packages/prisma/schema.prisma

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1715,7 +1715,8 @@ model CalendarCache {
17151715
key String
17161716
value Json
17171717
expiresAt DateTime
1718-
updatedAt DateTime @updatedAt
1718+
// Provide an initial value for legacy rows and future raw inserts
1719+
updatedAt DateTime @default(now()) @updatedAt
17191720
credentialId Int
17201721
userId Int?
17211722
credential Credential? @relation(fields: [credentialId], references: [id], onDelete: Cascade)

0 commit comments

Comments
 (0)