Skip to content

Commit

Permalink
update RecipeTag model to cascade on delete (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirisayshello authored Nov 18, 2024
1 parent 4db69eb commit 28fd32b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- DropForeignKey
ALTER TABLE "RecipeTag" DROP CONSTRAINT "RecipeTag_recipeId_fkey";

-- DropForeignKey
ALTER TABLE "RecipeTag" DROP CONSTRAINT "RecipeTag_tagId_fkey";

-- AddForeignKey
ALTER TABLE "RecipeTag" ADD CONSTRAINT "RecipeTag_recipeId_fkey" FOREIGN KEY ("recipeId") REFERENCES "Recipe"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "RecipeTag" ADD CONSTRAINT "RecipeTag_tagId_fkey" FOREIGN KEY ("tagId") REFERENCES "Tag"("id") ON DELETE CASCADE ON UPDATE CASCADE;
4 changes: 2 additions & 2 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ model Tag {
}

model RecipeTag {
recipe Recipe @relation(fields: [recipeId], references: [id])
recipe Recipe @relation(fields: [recipeId], references: [id], onDelete: Cascade)
recipeId Int
tag Tag @relation(fields: [tagId], references: [id])
tag Tag @relation(fields: [tagId], references: [id], onDelete: Cascade)
tagId Int
assignedAt DateTime @default(now())
Expand Down

0 comments on commit 28fd32b

Please sign in to comment.