diff --git a/apps/api/v1/test/lib/selected-calendars/_post.test.ts b/apps/api/v1/test/lib/selected-calendars/_post.test.ts index e872b116ce..5e23d003a2 100644 --- a/apps/api/v1/test/lib/selected-calendars/_post.test.ts +++ b/apps/api/v1/test/lib/selected-calendars/_post.test.ts @@ -93,6 +93,8 @@ describe("POST /api/selected-calendars", () => { watchAttempts: 0, maxAttempts: 3, unwatchAttempts: 0, + createdAt: new Date(), + updatedAt: new Date(), }); await handler(req, res); @@ -136,6 +138,8 @@ describe("POST /api/selected-calendars", () => { watchAttempts: 0, maxAttempts: 3, unwatchAttempts: 0, + createdAt: new Date(), + updatedAt: new Date(), }); await handler(req, res); diff --git a/apps/api/v2/src/modules/destination-calendars/controllers/destination-calendars.controller.e2e-spec.ts b/apps/api/v2/src/modules/destination-calendars/controllers/destination-calendars.controller.e2e-spec.ts index 9adce3ad1b..560f24d740 100644 --- a/apps/api/v2/src/modules/destination-calendars/controllers/destination-calendars.controller.e2e-spec.ts +++ b/apps/api/v2/src/modules/destination-calendars/controllers/destination-calendars.controller.e2e-spec.ts @@ -92,6 +92,8 @@ describe("Platform Destination Calendar Endpoints", () => { publisher: "", url: "", email: "", + createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), }, // calendars: { // externalId: @@ -118,6 +120,8 @@ describe("Platform Destination Calendar Endpoints", () => { id: 0, delegationCredentialId: null, domainWideDelegationCredentialId: null, + createdAt: new Date(), + updatedAt: new Date(), }, }) ); diff --git a/apps/api/v2/test/mocks/calendars-service-mock.ts b/apps/api/v2/test/mocks/calendars-service-mock.ts index cc58337958..bd91ae777b 100644 --- a/apps/api/v2/test/mocks/calendars-service-mock.ts +++ b/apps/api/v2/test/mocks/calendars-service-mock.ts @@ -75,6 +75,8 @@ export class CalendarsServiceMock { id: 0, delegationCredentialId: null, domainWideDelegationCredentialId: null, + createdAt: new Date(), + updatedAt: new Date(), }, } satisfies Awaited>; } diff --git a/packages/lib/buildCalEventFromBooking.ts b/packages/lib/buildCalEventFromBooking.ts index 209d8bdb59..9e0cb474c6 100644 --- a/packages/lib/buildCalEventFromBooking.ts +++ b/packages/lib/buildCalEventFromBooking.ts @@ -15,6 +15,8 @@ type DestinationCalendar = { credentialId: number | null; delegationCredentialId: string | null; domainWideDelegationCredentialId: string | null; + createdAt: Date | null; + updatedAt: Date | null; } | null; type Attendee = { diff --git a/packages/prisma/migrations/20250627195833_add_date_fields_to_calendar_records/migration.sql b/packages/prisma/migrations/20250627195833_add_date_fields_to_calendar_records/migration.sql new file mode 100644 index 0000000000..c14fdae614 --- /dev/null +++ b/packages/prisma/migrations/20250627195833_add_date_fields_to_calendar_records/migration.sql @@ -0,0 +1,7 @@ +-- AlterTable +ALTER TABLE "DestinationCalendar" ADD COLUMN "createdAt" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP, +ADD COLUMN "updatedAt" TIMESTAMP(3); + +-- AlterTable +ALTER TABLE "SelectedCalendar" ADD COLUMN "createdAt" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP, +ADD COLUMN "updatedAt" TIMESTAMP(3); diff --git a/packages/prisma/schema.prisma b/packages/prisma/schema.prisma index 61e071108f..bde1b9eb24 100644 --- a/packages/prisma/schema.prisma +++ b/packages/prisma/schema.prisma @@ -270,6 +270,8 @@ model DestinationCalendar { eventTypeId Int? @unique credentialId Int? credential Credential? @relation(fields: [credentialId], references: [id], onDelete: Cascade) + createdAt DateTime? @default(now()) + updatedAt DateTime? @updatedAt delegationCredential DelegationCredential? @relation(fields: [delegationCredentialId], references: [id], onDelete: Cascade) delegationCredentialId String? domainWideDelegation DomainWideDelegation? @relation(fields: [domainWideDelegationCredentialId], references: [id], onDelete: Cascade) @@ -854,6 +856,8 @@ model SelectedCalendar { externalId String credential Credential? @relation(fields: [credentialId], references: [id], onDelete: Cascade) credentialId Int? + createdAt DateTime? @default(now()) + updatedAt DateTime? @updatedAt // Used to identify a watched calendar channel in Google Calendar googleChannelId String? googleChannelKind String?