Skip to content

Commit

Permalink
Merge pull request #44 from oss-slu/42-update-prisma-schema-for-donat…
Browse files Browse the repository at this point in the history
…editem

fixed the cascade issue in schema
  • Loading branch information
Anjali0407-git authored Oct 8, 2024
2 parents dc21212 + 729e4ff commit df99f97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE "DonatedItemStatus" DROP CONSTRAINT "DonatedItemStatus_donatedItemId_fkey";

-- AddForeignKey
ALTER TABLE "DonatedItemStatus" ADD CONSTRAINT "DonatedItemStatus_donatedItemId_fkey" FOREIGN KEY ("donatedItemId") REFERENCES "DonatedItem"("id") ON DELETE CASCADE ON UPDATE CASCADE;
4 changes: 2 additions & 2 deletions server/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ model DonatedItem {
program String @db.VarChar(50) // Define as VARCHAR(50)
dateDonated DateTime
lastUpdated DateTime @updatedAt
statuses DonatedItemStatus[] @relation(onDelete: Cascade)// Relation to DonatedItemStatus
statuses DonatedItemStatus[] // Relation to DonatedItemStatus
}

model DonatedItemStatus {
id Int @id @default(autoincrement())
dateModified DateTime
statusType String @db.VarChar(20) // Define as VARCHAR(20)
donatedItemId Int
donatedItem DonatedItem @relation(fields: [donatedItemId], references: [id])
donatedItem DonatedItem @relation(fields: [donatedItemId], references: [id], onDelete: Cascade)
@@index([donatedItemId])
}
Expand Down

0 comments on commit df99f97

Please sign in to comment.