[offers][fix] Fix bug where offers are unable to be deleted due to being referenced by analysisUnit

pull/505/head
Bryann Yeap Kok Keong 2 years ago
parent 45a906bccf
commit 5e943047e2

@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE "OffersAnalysisUnit" DROP CONSTRAINT "OffersAnalysisUnit_analysedOfferId_fkey";
-- AddForeignKey
ALTER TABLE "OffersAnalysisUnit" ADD CONSTRAINT "OffersAnalysisUnit_analysedOfferId_fkey" FOREIGN KEY ("analysedOfferId") REFERENCES "OffersOffer"("id") ON DELETE CASCADE ON UPDATE CASCADE;

@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE "OffersAnalysis" DROP CONSTRAINT "OffersAnalysis_overallAnalysisUnitId_fkey";
-- AddForeignKey
ALTER TABLE "OffersAnalysis" ADD CONSTRAINT "OffersAnalysis_overallAnalysisUnitId_fkey" FOREIGN KEY ("overallAnalysisUnitId") REFERENCES "OffersAnalysisUnit"("id") ON DELETE CASCADE ON UPDATE CASCADE;

@ -410,7 +410,7 @@ model OffersAnalysis {
offerId String @unique offerId String @unique
// OVERALL // OVERALL
overallAnalysis OffersAnalysisUnit @relation("OverallAnalysis", fields: [overallAnalysisUnitId], references: [id]) overallAnalysis OffersAnalysisUnit @relation("OverallAnalysis", fields: [overallAnalysisUnitId], references: [id], onDelete: Cascade)
overallAnalysisUnitId String overallAnalysisUnitId String
companyAnalysis OffersAnalysisUnit[] @relation("CompanyAnalysis") companyAnalysis OffersAnalysisUnit[] @relation("CompanyAnalysis")
@ -419,7 +419,7 @@ model OffersAnalysis {
model OffersAnalysisUnit { model OffersAnalysisUnit {
id String @id @default(cuid()) id String @id @default(cuid())
analysedOffer OffersOffer @relation("Analysed Offer", fields: [analysedOfferId], references: [id]) analysedOffer OffersOffer @relation("Analysed Offer", fields: [analysedOfferId], references: [id], onDelete: Cascade)
analysedOfferId String analysedOfferId String
percentile Float percentile Float

Loading…
Cancel
Save