Skip to content

Commit

Permalink
🗃️ Cascade appartment deletion when user is deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
gwennlbh committed Apr 23, 2023
1 parent 153fb96 commit 25c3d96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE `Appartment` DROP FOREIGN KEY `Appartment_ownerId_fkey`;

-- AddForeignKey
ALTER TABLE `Appartment` ADD CONSTRAINT `Appartment_ownerId_fkey` FOREIGN KEY (`ownerId`) 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 @@ -103,7 +103,7 @@ model Appartment {
travelTimeToN7 TravelTimeToN7 @relation(fields: [travelTimeId], references: [id])
travelTimeId String
nearbyStations PublicTransportStation[]
owner User @relation(fields: [ownerId], references: [id])
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
ownerId String
createdByAdmin Boolean @default(false)
reports Report[]
Expand Down

0 comments on commit 25c3d96

Please sign in to comment.