From 3e949f5067829409d32d123aed9cc4860728bcf1 Mon Sep 17 00:00:00 2001 From: Madhura68 Date: Sat, 25 Apr 2026 19:16:49 +0200 Subject: [PATCH] feat(todos): make Todo.product_id nullable with SetNull on delete Todos can now exist without a product link. Changed relation from Cascade to SetNull so deleting a product doesn't delete unlinked todos. Co-Authored-By: Claude Sonnet 4.6 --- prisma/schema.prisma | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index c2b5e66..c258da6 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -217,8 +217,8 @@ model Todo { id String @id @default(cuid()) user User @relation(fields: [user_id], references: [id], onDelete: Cascade) user_id String - product Product @relation(fields: [product_id], references: [id], onDelete: Cascade) - product_id String + product Product? @relation(fields: [product_id], references: [id], onDelete: SetNull) + product_id String? title String done Boolean @default(false) archived Boolean @default(false)