From 57150d992e11fd707b9ffcfdf09d137c9e153639 Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Wed, 24 Sep 2025 12:55:27 +0200 Subject: [PATCH] fix: make createdById at Watchlist nullable (#24033) --- .../migration.sql | 8 ++++++++ packages/prisma/schema.prisma | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 packages/prisma/migrations/20250924091435_update_watchlist_created_by_id_fkey/migration.sql diff --git a/packages/prisma/migrations/20250924091435_update_watchlist_created_by_id_fkey/migration.sql b/packages/prisma/migrations/20250924091435_update_watchlist_created_by_id_fkey/migration.sql new file mode 100644 index 0000000000..41c43862d4 --- /dev/null +++ b/packages/prisma/migrations/20250924091435_update_watchlist_created_by_id_fkey/migration.sql @@ -0,0 +1,8 @@ +-- DropForeignKey +ALTER TABLE "Watchlist" DROP CONSTRAINT "Watchlist_createdById_fkey"; + +-- AlterTable +ALTER TABLE "Watchlist" ALTER COLUMN "createdById" DROP NOT NULL; + +-- AddForeignKey +ALTER TABLE "Watchlist" ADD CONSTRAINT "Watchlist_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/packages/prisma/schema.prisma b/packages/prisma/schema.prisma index 795becadcd..4f08fa2c63 100644 --- a/packages/prisma/schema.prisma +++ b/packages/prisma/schema.prisma @@ -2268,8 +2268,8 @@ model Watchlist { action WatchlistAction @default(REPORT) severity WatchlistSeverity @default(LOW) createdAt DateTime @default(now()) - createdBy User @relation("CreatedWatchlists", onDelete: SetNull, fields: [createdById], references: [id]) - createdById Int + createdBy User? @relation("CreatedWatchlists", onDelete: SetNull, fields: [createdById], references: [id]) + createdById Int? updatedAt DateTime @updatedAt updatedBy User? @relation("UpdatedWatchlists", onDelete: SetNull, fields: [updatedById], references: [id]) updatedById Int?