Skip to content

Commit

Permalink
Merge pull request #26 from bmviniciuss/fix/delete-cascade-post-delet…
Browse files Browse the repository at this point in the history
…e-user

fix/delete cascade post delete user
  • Loading branch information
bmviniciuss authored Jan 29, 2022
2 parents bc515af + 5627e35 commit bfe6991
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postpress",
"version": "1.0.0",
"version": "1.1.0",
"description": "1. [Database](./docs/database.md) 2. Routes 1. [User](./docs/user-routes.md)",
"main": "index.js",
"directories": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE "Post" DROP CONSTRAINT "Post_userId_fkey";

-- AddForeignKey
ALTER TABLE "Post" ADD CONSTRAINT "Post_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ model Post {
content String
userId String
user User @relation(fields: [userId], references: [id])
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
published DateTime @default(now())
updated DateTime @updatedAt
Expand Down

0 comments on commit bfe6991

Please sign in to comment.