mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-28 20:52:00 +08:00
[offers][fix] Fix generate analysis API by deleting analysis if exists before creating
This commit is contained in:
11
apps/portal/prisma/migrations/20221014211740_/migration.sql
Normal file
11
apps/portal/prisma/migrations/20221014211740_/migration.sql
Normal file
@ -0,0 +1,11 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "OffersAnalysis" DROP CONSTRAINT "OffersAnalysis_offerId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "OffersAnalysis" DROP CONSTRAINT "OffersAnalysis_profileId_fkey";
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "OffersAnalysis" ADD CONSTRAINT "OffersAnalysis_profileId_fkey" FOREIGN KEY ("profileId") REFERENCES "OffersProfile"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "OffersAnalysis" ADD CONSTRAINT "OffersAnalysis_offerId_fkey" FOREIGN KEY ("offerId") REFERENCES "OffersOffer"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
@ -358,10 +358,10 @@ model OffersFullTime {
|
||||
model OffersAnalysis {
|
||||
id String @id @default(cuid())
|
||||
|
||||
profile OffersProfile @relation(fields: [profileId], references: [id])
|
||||
profile OffersProfile @relation(fields: [profileId], references: [id], onDelete: Cascade)
|
||||
profileId String @unique
|
||||
|
||||
overallHighestOffer OffersOffer @relation("HighestOverallOffer", fields: [offerId], references: [id])
|
||||
overallHighestOffer OffersOffer @relation("HighestOverallOffer", fields: [offerId], references: [id], onDelete: Cascade)
|
||||
offerId String @unique
|
||||
|
||||
// OVERALL
|
||||
|
@ -71,6 +71,12 @@ export const offersAnalysisRouter = createRouter().query('generate', {
|
||||
profileId: z.string(),
|
||||
}),
|
||||
async resolve({ ctx, input }) {
|
||||
await ctx.prisma.offersAnalysis.deleteMany({
|
||||
where: {
|
||||
profileId: input.profileId,
|
||||
},
|
||||
});
|
||||
|
||||
const offers = await ctx.prisma.offersOffer.findMany({
|
||||
include: {
|
||||
OffersFullTime: {
|
||||
|
Reference in New Issue
Block a user