fix: OnDelete SetNull for watchlist delete on watchlistAudit (#25690)

* OnDelete SetNull for watchlist delete on watchlistAudit

* make watchlistId nullable

* type fix
This commit is contained in:
Syed Ali Shahbaz
2025-12-08 05:22:01 +00:00
committed by GitHub
parent 9631d0a64b
commit c78552ce60
4 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ export interface WatchlistAudit {
action: WatchlistAction;
changedAt: Date;
changedByUserId?: number | null;
watchlistId: string;
watchlistId: string | null;
}
export interface WatchlistEventAudit {
@@ -15,7 +15,7 @@ export interface WatchlistEntry {
export interface WatchlistAuditEntry {
id: string;
watchlistId: string;
watchlistId: string | null;
type: WatchlistType;
value: string;
description: string | null;
@@ -0,0 +1,8 @@
-- DropForeignKey
ALTER TABLE "public"."WatchlistAudit" DROP CONSTRAINT "WatchlistAudit_watchlistId_fkey";
-- AlterTable
ALTER TABLE "public"."WatchlistAudit" ALTER COLUMN "watchlistId" DROP NOT NULL;
-- AddForeignKey
ALTER TABLE "public"."WatchlistAudit" ADD CONSTRAINT "WatchlistAudit_watchlistId_fkey" FOREIGN KEY ("watchlistId") REFERENCES "public"."Watchlist"("id") ON DELETE SET NULL ON UPDATE CASCADE;
+2 -2
View File
@@ -2382,8 +2382,8 @@ model WatchlistAudit {
changedAt DateTime @default(now())
changedByUserId Int?
watchlistId String @db.Uuid
watchlist Watchlist? @relation(fields: [watchlistId], references: [id], onDelete: Cascade)
watchlistId String? @db.Uuid
watchlist Watchlist? @relation(fields: [watchlistId], references: [id], onDelete: SetNull)
@@index([watchlistId, changedAt])
}