Skip to content

Commit 0ab9823

Browse files
authored
chore: add createdAt field to SelectedCalendar and DestinationCalendar (calcom#22071)
* Add createdAt * Address feedback * Make date fields nullable * Type fixes * Type fix * Fix tests
1 parent b3fd4f3 commit 0ab9823

6 files changed

Lines changed: 23 additions & 0 deletions

File tree

apps/api/v1/test/lib/selected-calendars/_post.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ describe("POST /api/selected-calendars", () => {
9393
watchAttempts: 0,
9494
maxAttempts: 3,
9595
unwatchAttempts: 0,
96+
createdAt: new Date(),
97+
updatedAt: new Date(),
9698
});
9799

98100
await handler(req, res);
@@ -136,6 +138,8 @@ describe("POST /api/selected-calendars", () => {
136138
watchAttempts: 0,
137139
maxAttempts: 3,
138140
unwatchAttempts: 0,
141+
createdAt: new Date(),
142+
updatedAt: new Date(),
139143
});
140144

141145
await handler(req, res);

apps/api/v2/src/modules/destination-calendars/controllers/destination-calendars.controller.e2e-spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ describe("Platform Destination Calendar Endpoints", () => {
9292
publisher: "",
9393
url: "",
9494
email: "",
95+
createdAt: new Date().toISOString(),
96+
updatedAt: new Date().toISOString(),
9597
},
9698
// calendars: {
9799
// externalId:
@@ -118,6 +120,8 @@ describe("Platform Destination Calendar Endpoints", () => {
118120
id: 0,
119121
delegationCredentialId: null,
120122
domainWideDelegationCredentialId: null,
123+
createdAt: new Date(),
124+
updatedAt: new Date(),
121125
},
122126
})
123127
);

apps/api/v2/test/mocks/calendars-service-mock.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export class CalendarsServiceMock {
7575
id: 0,
7676
delegationCredentialId: null,
7777
domainWideDelegationCredentialId: null,
78+
createdAt: new Date(),
79+
updatedAt: new Date(),
7880
},
7981
} satisfies Awaited<ReturnType<typeof CalendarsService.prototype.getCalendars>>;
8082
}

packages/lib/buildCalEventFromBooking.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ type DestinationCalendar = {
1515
credentialId: number | null;
1616
delegationCredentialId: string | null;
1717
domainWideDelegationCredentialId: string | null;
18+
createdAt: Date | null;
19+
updatedAt: Date | null;
1820
} | null;
1921

2022
type Attendee = {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- AlterTable
2+
ALTER TABLE "DestinationCalendar" ADD COLUMN "createdAt" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
3+
ADD COLUMN "updatedAt" TIMESTAMP(3);
4+
5+
-- AlterTable
6+
ALTER TABLE "SelectedCalendar" ADD COLUMN "createdAt" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
7+
ADD COLUMN "updatedAt" TIMESTAMP(3);

packages/prisma/schema.prisma

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ model DestinationCalendar {
270270
eventTypeId Int? @unique
271271
credentialId Int?
272272
credential Credential? @relation(fields: [credentialId], references: [id], onDelete: Cascade)
273+
createdAt DateTime? @default(now())
274+
updatedAt DateTime? @updatedAt
273275
delegationCredential DelegationCredential? @relation(fields: [delegationCredentialId], references: [id], onDelete: Cascade)
274276
delegationCredentialId String?
275277
domainWideDelegation DomainWideDelegation? @relation(fields: [domainWideDelegationCredentialId], references: [id], onDelete: Cascade)
@@ -854,6 +856,8 @@ model SelectedCalendar {
854856
externalId String
855857
credential Credential? @relation(fields: [credentialId], references: [id], onDelete: Cascade)
856858
credentialId Int?
859+
createdAt DateTime? @default(now())
860+
updatedAt DateTime? @updatedAt
857861
// Used to identify a watched calendar channel in Google Calendar
858862
googleChannelId String?
859863
googleChannelKind String?

0 commit comments

Comments
 (0)