[offers][chore] Change location in schema

pull/491/head
Bryann Yeap Kok Keong 3 years ago
parent ea57743cfe
commit 252feda82d

@ -0,0 +1,21 @@
/*
Warnings:
- You are about to drop the column `location` on the `OffersExperience` table. All the data in the column will be lost.
- You are about to drop the column `location` on the `OffersOffer` table. All the data in the column will be lost.
- Added the required column `cityId` to the `OffersOffer` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "OffersExperience" DROP COLUMN "location",
ADD COLUMN "cityId" TEXT;
-- AlterTable
ALTER TABLE "OffersOffer" DROP COLUMN "location",
ADD COLUMN "cityId" TEXT NOT NULL;
-- AddForeignKey
ALTER TABLE "OffersExperience" ADD CONSTRAINT "OffersExperience_cityId_fkey" FOREIGN KEY ("cityId") REFERENCES "City"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "OffersOffer" ADD CONSTRAINT "OffersOffer_cityId_fkey" FOREIGN KEY ("cityId") REFERENCES "City"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

@ -131,6 +131,8 @@ model City {
stateId String stateId String
state State @relation(fields: [stateId], references: [id]) state State @relation(fields: [stateId], references: [id])
questionsQuestionEncounters QuestionsQuestionEncounter[] questionsQuestionEncounters QuestionsQuestionEncounter[]
OffersExperience OffersExperience[]
OffersOffer OffersOffer[]
@@unique([name, stateId]) @@unique([name, stateId])
} }
@ -265,7 +267,8 @@ model OffersExperience {
// Add more fields // Add more fields
durationInMonths Int? durationInMonths Int?
location String? location City? @relation(fields: [cityId], references: [id])
cityId String?
// FULLTIME fields // FULLTIME fields
level String? level String?
@ -348,8 +351,9 @@ model OffersOffer {
company Company @relation(fields: [companyId], references: [id]) company Company @relation(fields: [companyId], references: [id])
companyId String companyId String
location City @relation(fields: [cityId], references: [id])
cityId String
monthYearReceived DateTime monthYearReceived DateTime
location String
negotiationStrategy String negotiationStrategy String
comments String comments String

@ -171,6 +171,15 @@ export const offersProfileRouter = createRouter()
topSimilarOffers: { topSimilarOffers: {
include: { include: {
company: true, company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: { offersFullTime: {
include: { include: {
totalCompensation: true, totalCompensation: true,
@ -188,6 +197,15 @@ export const offersProfileRouter = createRouter()
experiences: { experiences: {
include: { include: {
company: true, company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
}, },
}, },
}, },
@ -203,6 +221,15 @@ export const offersProfileRouter = createRouter()
topSimilarOffers: { topSimilarOffers: {
include: { include: {
company: true, company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: { offersFullTime: {
include: { include: {
totalCompensation: true, totalCompensation: true,
@ -220,6 +247,15 @@ export const offersProfileRouter = createRouter()
experiences: { experiences: {
include: { include: {
company: true, company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
}, },
}, },
}, },
@ -233,6 +269,15 @@ export const offersProfileRouter = createRouter()
overallHighestOffer: { overallHighestOffer: {
include: { include: {
company: true, company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: { offersFullTime: {
include: { include: {
totalCompensation: true, totalCompensation: true,
@ -258,6 +303,15 @@ export const offersProfileRouter = createRouter()
experiences: { experiences: {
include: { include: {
company: true, company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
monthlySalary: true, monthlySalary: true,
totalCompensation: true, totalCompensation: true,
}, },
@ -275,6 +329,15 @@ export const offersProfileRouter = createRouter()
offers: { offers: {
include: { include: {
company: true, company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: { offersFullTime: {
include: { include: {
baseSalary: true, baseSalary: true,
@ -809,14 +872,14 @@ export const offersProfileRouter = createRouter()
), ),
currency: exp.monthlySalary.currency, currency: exp.monthlySalary.currency,
value: exp.monthlySalary.value, value: exp.monthlySalary.value,
} },
} },
} },
}, },
where: { where: {
id: exp.id id: exp.id,
} },
}) });
} }
if (exp.totalCompensation) { if (exp.totalCompensation) {
@ -843,14 +906,14 @@ export const offersProfileRouter = createRouter()
), ),
currency: exp.totalCompensation.currency, currency: exp.totalCompensation.currency,
value: exp.totalCompensation.value, value: exp.totalCompensation.value,
} },
} },
} },
}, },
where: { where: {
id: exp.id id: exp.id,
} },
}) });
} }
} else if (!exp.id) { } else if (!exp.id) {
// Create new experience // Create new experience
@ -1176,7 +1239,8 @@ export const offersProfileRouter = createRouter()
offerToUpdate.offersIntern.monthlySalary.currency, offerToUpdate.offersIntern.monthlySalary.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: offerToUpdate.offersIntern.monthlySalary.currency, currency:
offerToUpdate.offersIntern.monthlySalary.currency,
value: offerToUpdate.offersIntern.monthlySalary.value, value: offerToUpdate.offersIntern.monthlySalary.value,
}, },
update: { update: {
@ -1186,13 +1250,14 @@ export const offersProfileRouter = createRouter()
offerToUpdate.offersIntern.monthlySalary.currency, offerToUpdate.offersIntern.monthlySalary.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: offerToUpdate.offersIntern.monthlySalary.currency, currency:
offerToUpdate.offersIntern.monthlySalary.currency,
value: offerToUpdate.offersIntern.monthlySalary.value, value: offerToUpdate.offersIntern.monthlySalary.value,
} },
} },
}, },
startYear: offerToUpdate.offersIntern.startYear ?? undefined, startYear: offerToUpdate.offersIntern.startYear ?? undefined,
title: offerToUpdate.offersIntern.title title: offerToUpdate.offersIntern.title,
}, },
where: { where: {
id: offerToUpdate.offersIntern.id, id: offerToUpdate.offersIntern.id,
@ -1222,7 +1287,8 @@ export const offersProfileRouter = createRouter()
offerToUpdate.offersFullTime.baseSalary.currency, offerToUpdate.offersFullTime.baseSalary.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: offerToUpdate.offersFullTime.baseSalary.currency, currency:
offerToUpdate.offersFullTime.baseSalary.currency,
value: offerToUpdate.offersFullTime.baseSalary.value, value: offerToUpdate.offersFullTime.baseSalary.value,
}, },
update: { update: {
@ -1232,11 +1298,12 @@ export const offersProfileRouter = createRouter()
offerToUpdate.offersFullTime.baseSalary.currency, offerToUpdate.offersFullTime.baseSalary.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: offerToUpdate.offersFullTime.baseSalary.currency, currency:
offerToUpdate.offersFullTime.baseSalary.currency,
value: offerToUpdate.offersFullTime.baseSalary.value, value: offerToUpdate.offersFullTime.baseSalary.value,
} },
} },
} },
}, },
where: { where: {
id: offerToUpdate.offersFullTime.id, id: offerToUpdate.offersFullTime.id,
@ -1267,9 +1334,9 @@ export const offersProfileRouter = createRouter()
), ),
currency: offerToUpdate.offersFullTime.bonus.currency, currency: offerToUpdate.offersFullTime.bonus.currency,
value: offerToUpdate.offersFullTime.bonus.value, value: offerToUpdate.offersFullTime.bonus.value,
} },
} },
} },
}, },
where: { where: {
id: offerToUpdate.offersFullTime.id, id: offerToUpdate.offersFullTime.id,
@ -1288,7 +1355,8 @@ export const offersProfileRouter = createRouter()
offerToUpdate.offersFullTime.stocks.currency, offerToUpdate.offersFullTime.stocks.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: offerToUpdate.offersFullTime.stocks.currency, currency:
offerToUpdate.offersFullTime.stocks.currency,
value: offerToUpdate.offersFullTime.stocks.value, value: offerToUpdate.offersFullTime.stocks.value,
}, },
update: { update: {
@ -1298,11 +1366,12 @@ export const offersProfileRouter = createRouter()
offerToUpdate.offersFullTime.stocks.currency, offerToUpdate.offersFullTime.stocks.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: offerToUpdate.offersFullTime.stocks.currency, currency:
offerToUpdate.offersFullTime.stocks.currency,
value: offerToUpdate.offersFullTime.stocks.value, value: offerToUpdate.offersFullTime.stocks.value,
} },
} },
} },
}, },
where: { where: {
id: offerToUpdate.offersFullTime.id, id: offerToUpdate.offersFullTime.id,
@ -1317,24 +1386,32 @@ export const offersProfileRouter = createRouter()
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
baseValue: await convert( baseValue: await convert(
offerToUpdate.offersFullTime.totalCompensation.value, offerToUpdate.offersFullTime.totalCompensation.value,
offerToUpdate.offersFullTime.totalCompensation.currency, offerToUpdate.offersFullTime.totalCompensation
.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: offerToUpdate.offersFullTime.totalCompensation.currency, currency:
value: offerToUpdate.offersFullTime.totalCompensation.value, offerToUpdate.offersFullTime.totalCompensation
.currency,
value:
offerToUpdate.offersFullTime.totalCompensation.value,
}, },
update: { update: {
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
baseValue: await convert( baseValue: await convert(
offerToUpdate.offersFullTime.totalCompensation.value, offerToUpdate.offersFullTime.totalCompensation.value,
offerToUpdate.offersFullTime.totalCompensation.currency, offerToUpdate.offersFullTime.totalCompensation
.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: offerToUpdate.offersFullTime.totalCompensation.currency, currency:
value: offerToUpdate.offersFullTime.totalCompensation.value, offerToUpdate.offersFullTime.totalCompensation
} .currency,
} value:
} offerToUpdate.offersFullTime.totalCompensation.value,
},
},
},
}, },
where: { where: {
id: offerToUpdate.offersFullTime.id, id: offerToUpdate.offersFullTime.id,

Loading…
Cancel
Save