feat: add uuidv7 and @db.Uuid to AuditActor and BookingAudit models (#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>
This commit is contained in:
Hariom Balhara
2025-11-19 13:17:02 +00:00
committed by GitHub
co-authored by Devin AI
parent fdd3d11111
commit 105a82f97d
2 changed files with 22 additions and 2 deletions
@@ -0,0 +1,20 @@
/*
Warnings:
- The primary key for the `AuditActor` table will be changed. If it partially fails, the table could be left without primary key constraint.
- 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.
- Changed the type of `actorId` on the `BookingAudit` table to UUID.
*/
ALTER TABLE "public"."BookingAudit" DROP CONSTRAINT "BookingAudit_actorId_fkey";
ALTER TABLE "public"."BookingAudit" ALTER COLUMN "actorId" TYPE UUID USING "actorId"::UUID;
ALTER TABLE "public"."AuditActor" DROP CONSTRAINT "AuditActor_pkey";
ALTER TABLE "public"."AuditActor" ALTER COLUMN "id" TYPE UUID USING "id"::UUID;
ALTER TABLE "public"."AuditActor" ADD CONSTRAINT "AuditActor_pkey" PRIMARY KEY ("id");
ALTER TABLE "public"."BookingAudit" ADD CONSTRAINT "BookingAudit_actorId_fkey" FOREIGN KEY ("actorId") REFERENCES "public"."AuditActor"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
+2 -2
View File
@@ -2671,7 +2671,7 @@ enum AuditActorType {
}
model AuditActor {
id String @id @default(uuid())
id String @id @default(uuid(7)) @db.Uuid
type AuditActorType
// References for different actor types (soft references, no FK constraints)
@@ -2712,7 +2712,7 @@ model BookingAudit {
// Actor who performed the action (USER, GUEST, or SYSTEM)
// Stored in AuditActor table to maintain audit trail even after user deletion
actorId String
actorId String @db.Uuid
// Restrict onDelete to prevent deletion of audit actor if there are any booking audits associated with it
actor AuditActor @relation(fields: [actorId], references: [id], onDelete: Restrict)