Skip to content

Commit

Permalink
feat(api): cascade budget users when delete budget
Browse files Browse the repository at this point in the history
  • Loading branch information
bkdev98 committed Aug 20, 2024
1 parent 6a23563 commit 96bd899
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 "BudgetUser" DROP CONSTRAINT "BudgetUser_budgetId_fkey";

-- DropForeignKey
ALTER TABLE "BudgetUser" DROP CONSTRAINT "BudgetUser_userId_fkey";

-- AddForeignKey
ALTER TABLE "BudgetUser" ADD CONSTRAINT "BudgetUser_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "BudgetUser" ADD CONSTRAINT "BudgetUser_budgetId_fkey" FOREIGN KEY ("budgetId") REFERENCES "Budget"("id") ON DELETE CASCADE ON UPDATE CASCADE;
4 changes: 2 additions & 2 deletions apps/api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ model BudgetUser {
permission BudgetUserPermission
userId String
user User @relation(fields: [userId], references: [id])
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
budgetId String
budget Budget @relation(fields: [budgetId], references: [id])
budget Budget @relation(fields: [budgetId], references: [id], onDelete: Cascade)
@@unique([userId, budgetId])
}
Expand Down

0 comments on commit 96bd899

Please sign in to comment.