chore: Set the stage for a primary key with value uuid() (#18245)
* chore: Set the stage for a primary key with value uuid() * fix: Test and ensure it validates the id value is set and defined * Add unique index manually, prisma doesn't support this * revert unique
This commit is contained in:
1 parent
8dda418127
commit
4ab3ec73c0
3 files changed
+40
-24
No files matched your search
@@ -136,18 +136,23 @@ test("Calendar can be watched and unwatched", async () => {
|
||||
integration: "google_calendar",
|
||||
},
|
||||
});
|
||||
expect(watchedCalendar).toEqual({
|
||||
userId: 1,
|
||||
integration: "google_calendar",
|
||||
externalId: "example@cal.com",
|
||||
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: "example@cal.com",
|
||||
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 element
|
||||
const [, 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: "example@cal.com",
|
||||
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: "example@cal.com",
|
||||
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 () => {
|
||||
|
||||
+5
@@ -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;
|
||||
@@ -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 Int
|
||||
integration String
|
||||
|
||||
Reference in new issue
Block a user