Scheduling infrastructure for absolutely everyone.
chore: Set the stage for a primary key with value uuid() (#18245)
Alex van Andel4ab3ec73c038
diff --git a/packages/app-store/googlecalendar/lib/CalendarService.test.ts b/packages/app-store/googlecalendar/lib/CalendarService.test.tsindex 87aab1cc2c1..fc7ae8541a5 100644--- a/packages/app-store/googlecalendar/lib/CalendarService.test.ts+++ b/packages/app-store/googlecalendar/lib/CalendarService.test.ts@@ -136,18 +136,23 @@ test("Calendar can be watched and unwatched", async () => {integration: "google_calendar",},});- expect(watchedCalendar).toEqual({- userId: 1,- integration: "google_calendar",- externalId: "[email protected]",- credentialId: 1,- domainWideDelegationCredentialId: null,- googleChannelId: "mock-channel-id",- googleChannelKind: "api#channel",- googleChannelResourceId: "mock-resource-id",- googleChannelResourceUri: "mock-resource-uri",- googleChannelExpiration: "1111111111",- });+ expect(watchedCalendar).toEqual(+ expect.objectContaining({+ userId: 1,+ integration: "google_calendar",+ externalId: "[email protected]",+ credentialId: 1,+ domainWideDelegationCredentialId: null,+ googleChannelId: "mock-channel-id",+ googleChannelKind: "api#channel",+ googleChannelResourceId: "mock-resource-id",+ googleChannelResourceUri: "mock-resource-uri",+ googleChannelExpiration: "1111111111",+ })+ );++ expect(watchedCalendar?.id).toBeDefined();+await calendarCache.unwatchCalendar({ calendarId: testSelectedCalendar.externalId });// There's a bug in prismock where upsert creates duplicate records so we need to acces the second elementconst [, unWatchedCalendar] = await prismock.selectedCalendar.findMany({@@ -158,18 +163,22 @@ test("Calendar can be watched and unwatched", async () => {},});- expect(unWatchedCalendar).toEqual({- userId: 1,- integration: "google_calendar",- externalId: "[email protected]",- credentialId: 1,- domainWideDelegationCredentialId: null,- googleChannelId: null,- googleChannelKind: null,- googleChannelResourceId: null,- googleChannelResourceUri: null,- googleChannelExpiration: null,- });+ expect(unWatchedCalendar).toEqual(+ expect.objectContaining({+ userId: 1,+ integration: "google_calendar",+ externalId: "[email protected]",+ credentialId: 1,+ domainWideDelegationCredentialId: null,+ googleChannelId: null,+ googleChannelKind: null,+ googleChannelResourceId: null,+ googleChannelResourceUri: null,+ googleChannelExpiration: null,+ })+ );++ expect(unWatchedCalendar?.id).toBeDefined();});test("`updateTokenObject` should update credential in DB as well as myGoogleAuth", async () => {diff --git a/packages/prisma/migrations/20241218125130_add_optional_uuid_two_step_primary_key/migration.sql b/packages/prisma/migrations/20241218125130_add_optional_uuid_two_step_primary_key/migration.sqlnew file mode 100644index 00000000000..6d110e0419f--- /dev/null+++ b/packages/prisma/migrations/20241218125130_add_optional_uuid_two_step_primary_key/migration.sql@@ -0,0 +1,5 @@+-- AlterTable+ALTER TABLE "SelectedCalendar" ADD COLUMN "id" TEXT;++-- Update all historical rows (id) to `gen_random_uuid`+UPDATE "SelectedCalendar" SET "id" = gen_random_uuid() WHERE "id" IS NULL;\ No newline at end of filediff --git a/packages/prisma/schema.prisma b/packages/prisma/schema.prismaindex 4da67c66f6a..1f0fde1ab9b 100644--- a/packages/prisma/schema.prisma+++ b/packages/prisma/schema.prisma@@ -709,6 +709,8 @@ model Availability {}model SelectedCalendar {+ // Will become required and @id in a seperate PR+ id String? @default(uuid())user User @relation(fields: [userId], references: [id], onDelete: Cascade)userId Intintegration String