chore: add delete cascade

This commit is contained in:
Catalin Pit
2023-12-20 14:44:43 +02:00
parent fb46b09e4f
commit a22ada5f41
2 changed files with 6 additions and 1 deletions

View File

@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE "ApiToken" DROP CONSTRAINT "ApiToken_userId_fkey";
-- AddForeignKey
ALTER TABLE "ApiToken" ADD CONSTRAINT "ApiToken_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -76,7 +76,7 @@ model ApiToken {
expires DateTime
createdAt DateTime @default(now())
userId Int
user User @relation(fields: [userId], references: [id])
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
enum SubscriptionStatus {