Skip to content

Commit 105a82f

Browse files
feat: add uuidv7 and @db.Uuid to AuditActor and BookingAudit models (calcom#25269)
- Update AuditActor.id to use uuid(7) with @db.Uuid - Add @db.Uuid to BookingAudit.bookingUid and actorId fields - Create migration to convert existing TEXT columns to UUID type Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent fdd3d11 commit 105a82f

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
Warnings:
3+
4+
- The primary key for the `AuditActor` table will be changed. If it partially fails, the table could be left without primary key constraint.
5+
- Changed the type of `id` on the `AuditActor` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
6+
- Changed the type of `actorId` on the `BookingAudit` table to UUID.
7+
8+
*/
9+
10+
ALTER TABLE "public"."BookingAudit" DROP CONSTRAINT "BookingAudit_actorId_fkey";
11+
12+
ALTER TABLE "public"."BookingAudit" ALTER COLUMN "actorId" TYPE UUID USING "actorId"::UUID;
13+
14+
ALTER TABLE "public"."AuditActor" DROP CONSTRAINT "AuditActor_pkey";
15+
16+
ALTER TABLE "public"."AuditActor" ALTER COLUMN "id" TYPE UUID USING "id"::UUID;
17+
18+
ALTER TABLE "public"."AuditActor" ADD CONSTRAINT "AuditActor_pkey" PRIMARY KEY ("id");
19+
20+
ALTER TABLE "public"."BookingAudit" ADD CONSTRAINT "BookingAudit_actorId_fkey" FOREIGN KEY ("actorId") REFERENCES "public"."AuditActor"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

packages/prisma/schema.prisma

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,7 +2671,7 @@ enum AuditActorType {
26712671
}
26722672

26732673
model AuditActor {
2674-
id String @id @default(uuid())
2674+
id String @id @default(uuid(7)) @db.Uuid
26752675
type AuditActorType
26762676
26772677
// References for different actor types (soft references, no FK constraints)
@@ -2712,7 +2712,7 @@ model BookingAudit {
27122712
27132713
// Actor who performed the action (USER, GUEST, or SYSTEM)
27142714
// Stored in AuditActor table to maintain audit trail even after user deletion
2715-
actorId String
2715+
actorId String @db.Uuid
27162716
// Restrict onDelete to prevent deletion of audit actor if there are any booking audits associated with it
27172717
actor AuditActor @relation(fields: [actorId], references: [id], onDelete: Restrict)
27182718

0 commit comments

Comments
 (0)