Cascades impersonations on user delete (#2891)

Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
Omar LópezandAlex van Andel authored and GitHub committed 2022-05-26 15:48:02 +00:00
1 parent a0a4ff6ce6
commit 9710c6faa6
2 files changed
+13 -2

No files matched your search

@@ -0,0 +1,11 @@
-- DropForeignKey
ALTER TABLE "Impersonations" DROP CONSTRAINT "Impersonations_impersonatedById_fkey";
-- DropForeignKey
ALTER TABLE "Impersonations" DROP CONSTRAINT "Impersonations_impersonatedUserId_fkey";
-- AddForeignKey
ALTER TABLE "Impersonations" ADD CONSTRAINT "Impersonations_impersonatedUserId_fkey" FOREIGN KEY ("impersonatedUserId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Impersonations" ADD CONSTRAINT "Impersonations_impersonatedById_fkey" FOREIGN KEY ("impersonatedById") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+2 -2
View File
@@ -402,8 +402,8 @@ model Webhook {
model Impersonations {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
impersonatedUser User @relation("impersonated_user", fields: [impersonatedUserId], references: [id])
impersonatedBy User @relation("impersonated_by_user", fields: [impersonatedById], references: [id])
impersonatedUser User @relation("impersonated_user", fields: [impersonatedUserId], references: [id], onDelete: Cascade)
impersonatedBy User @relation("impersonated_by_user", fields: [impersonatedById], references: [id], onDelete: Cascade)
impersonatedUserId Int
impersonatedById Int
}