From 6c7459c61f3f05b73d873aa9c9358d5492c9cd99 Mon Sep 17 00:00:00 2001 From: Madhura68 Date: Sat, 25 Apr 2026 18:42:47 +0200 Subject: [PATCH] feat(db): make Todo.product_id non-nullable, cascade on product delete MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Aligns schema with the API and server action, both of which already require product_id. Changes onDelete from SetNull to Cascade — deleting a product now also removes its todos. Run: npx prisma db push 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 c258da6..c2b5e66 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: SetNull) - product_id String? + product Product @relation(fields: [product_id], references: [id], onDelete: Cascade) + product_id String title String done Boolean @default(false) archived Boolean @default(false)