diff --git a/services/app-api/prisma/migrations/20230713173904_move_addtl_actuary_and_comm_preference_to_rate_revision/migration.sql b/services/app-api/prisma/migrations/20230713173904_move_addtl_actuary_and_comm_preference_to_rate_revision/migration.sql new file mode 100644 index 0000000000..a4042373da --- /dev/null +++ b/services/app-api/prisma/migrations/20230713173904_move_addtl_actuary_and_comm_preference_to_rate_revision/migration.sql @@ -0,0 +1,30 @@ +BEGIN; +/* + Warnings: + + - You are about to drop the column `contractRevisionID` on the `ActuaryContact` table. All the data in the column will be lost. + - You are about to drop the column `rateRevisionID` on the `ActuaryContact` table. All the data in the column will be lost. + - You are about to drop the column `addtlActuaryCommunicationPreference` on the `ContractRevisionTable` table. All the data in the column will be lost. + +*/ +-- DropForeignKey +ALTER TABLE "ActuaryContact" DROP CONSTRAINT "ActuaryContact_contractRevisionID_fkey"; + +-- DropForeignKey +ALTER TABLE "ActuaryContact" DROP CONSTRAINT "ActuaryContact_rateRevisionID_fkey"; + +-- AlterTable +ALTER TABLE "ActuaryContact" DROP COLUMN "contractRevisionID", +DROP COLUMN "rateRevisionID", +ADD COLUMN "rateWithAddtlActuaryID" TEXT, +ADD COLUMN "rateWithCertifyingActuaryID" TEXT; + +-- AlterTable +ALTER TABLE "ContractRevisionTable" DROP COLUMN "addtlActuaryCommunicationPreference"; + +-- AddForeignKey +ALTER TABLE "ActuaryContact" ADD CONSTRAINT "ActuaryContact_rateWithCertifyingActuaryID_fkey" FOREIGN KEY ("rateWithCertifyingActuaryID") REFERENCES "RateRevisionTable"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ActuaryContact" ADD CONSTRAINT "ActuaryContact_rateWithAddtlActuaryID_fkey" FOREIGN KEY ("rateWithAddtlActuaryID") REFERENCES "RateRevisionTable"("id") ON DELETE SET NULL ON UPDATE CASCADE; +COMMIT; diff --git a/services/app-api/prisma/schema.prisma b/services/app-api/prisma/schema.prisma index f3de8ff158..e3ffbe5692 100644 --- a/services/app-api/prisma/schema.prisma +++ b/services/app-api/prisma/schema.prisma @@ -83,8 +83,6 @@ model ContractRevisionTable { populationCovered PopulationCoverageType? riskBasedContract Boolean? stateContacts StateContact[] - addtlActuaryContacts ActuaryContact[] - addtlActuaryCommunicationPreference ActuaryCommunication? supportingDocuments ContractSupportingDocument[] contractType ContractType contractExecutionStatus ContractExecutionStatus? @@ -138,7 +136,8 @@ model RateRevisionTable { amendmentEffectiveDateEnd DateTime? @db.Date rateProgramIDs String[] rateCertificationName String? - actuaryContacts ActuaryContact[] + certifyingActuaryContacts ActuaryContact[] @relation(name: "CertifyingActuaryOnRateRevision") + addtlActuaryContacts ActuaryContact[] @relation(name: "AddtlActuaryOnRateRevision") actuaryCommunicationPreference ActuaryCommunication? packagesWithSharedRateCerts SharedRateCertifications[] } @@ -163,9 +162,9 @@ model UpdateInfoTable { updatedBy User @relation(fields: [updatedByID], references: [id]) updatedReason String unlockedContracts ContractRevisionTable[] @relation("unlockContractInfo") - submitedContracts ContractRevisionTable[] @relation("submitContractInfo") + submittedContracts ContractRevisionTable[] @relation("submitContractInfo") unlockedRates RateRevisionTable[] @relation("unlockRateInfo") - submitedRates RateRevisionTable[] @relation("submitRateInfo") + submittedRates RateRevisionTable[] @relation("submitRateInfo") } model SharedRateCertifications { @@ -185,10 +184,10 @@ model ActuaryContact { email String actuarialFirm ActuarialFirm actuarialFirmOther String? - contractRevisionID String? - contractRevision ContractRevisionTable? @relation(fields: [contractRevisionID], references: [id]) - rateRevisionID String? - rateRevision RateRevisionTable? @relation(fields: [rateRevisionID], references: [id]) + rateWithCertifyingActuaryID String? + rateWithAddtlActuaryID String? + rateActuaryCertifying RateRevisionTable? @relation(name: "CertifyingActuaryOnRateRevision", fields: [ rateWithCertifyingActuaryID ], references: [id]) + rateActuaryAddtl RateRevisionTable? @relation(name: "AddtlActuaryOnRateRevision", fields: [ rateWithAddtlActuaryID ], references: [id]) } model ContractDocument { diff --git a/services/app-api/src/postgres/contractAndRates/findContractWithHistory.ts b/services/app-api/src/postgres/contractAndRates/findContractWithHistory.ts index 4707757a78..65e6a6a3f0 100644 --- a/services/app-api/src/postgres/contractAndRates/findContractWithHistory.ts +++ b/services/app-api/src/postgres/contractAndRates/findContractWithHistory.ts @@ -38,7 +38,6 @@ async function findContractWithHistory( }, }, stateContacts: true, - addtlActuaryContacts: true, contractDocuments: true, supportingDocuments: true, }, diff --git a/services/app-api/src/postgres/contractAndRates/findDraftRate.ts b/services/app-api/src/postgres/contractAndRates/findDraftRate.ts index 35e76085f3..31175a2dd6 100644 --- a/services/app-api/src/postgres/contractAndRates/findDraftRate.ts +++ b/services/app-api/src/postgres/contractAndRates/findDraftRate.ts @@ -24,7 +24,6 @@ async function findDraftRate( submitInfo: updateInfoIncludeUpdater, unlockInfo: updateInfoIncludeUpdater, stateContacts: true, - addtlActuaryContacts: true, contractDocuments: true, supportingDocuments: true, rateRevisions: { diff --git a/services/app-api/src/postgres/contractAndRates/findRateWithHistory.ts b/services/app-api/src/postgres/contractAndRates/findRateWithHistory.ts index 224e671986..9f92559253 100644 --- a/services/app-api/src/postgres/contractAndRates/findRateWithHistory.ts +++ b/services/app-api/src/postgres/contractAndRates/findRateWithHistory.ts @@ -42,7 +42,6 @@ async function findRateWithHistory( submitInfo: updateInfoIncludeUpdater, unlockInfo: updateInfoIncludeUpdater, stateContacts: true, - addtlActuaryContacts: true, contractDocuments: true, supportingDocuments: true, rateRevisions: { diff --git a/services/app-api/src/postgres/contractAndRates/insertRate.ts b/services/app-api/src/postgres/contractAndRates/insertRate.ts index 5dd06b3958..621b2d44b3 100644 --- a/services/app-api/src/postgres/contractAndRates/insertRate.ts +++ b/services/app-api/src/postgres/contractAndRates/insertRate.ts @@ -48,7 +48,6 @@ async function insertDraftRate( }, }, stateContacts: true, - addtlActuaryContacts: true, contractDocuments: true, supportingDocuments: true, }, diff --git a/services/app-api/src/postgres/contractAndRates/prismaToDomainModel.ts b/services/app-api/src/postgres/contractAndRates/prismaToDomainModel.ts index 6ecbc63990..b5a3658b7f 100644 --- a/services/app-api/src/postgres/contractAndRates/prismaToDomainModel.ts +++ b/services/app-api/src/postgres/contractAndRates/prismaToDomainModel.ts @@ -72,17 +72,6 @@ function contractFormDataToDomainModel( email: contact.email, })) : [], - addtlActuaryContacts: contractRevision.addtlActuaryContacts - ? contractRevision.addtlActuaryContacts.map((contact) => ({ - name: contact.name, - titleRole: contact.titleRole, - email: contact.email, - actuarialFirm: contact.actuarialFirm, - actuarialFirmOther: contact.actuarialFirmOther ?? undefined, - })) - : [], - addtlActuaryCommunicationPreference: - contractRevision.addtlActuaryCommunicationPreference ?? undefined, supportingDocuments: contractRevision.supportingDocuments ? contractRevision.supportingDocuments.map((doc) => ({ name: doc.name, diff --git a/services/app-api/src/postgres/prismaHelpers.ts b/services/app-api/src/postgres/prismaHelpers.ts index 02a96fd42a..a08fbc8b49 100644 --- a/services/app-api/src/postgres/prismaHelpers.ts +++ b/services/app-api/src/postgres/prismaHelpers.ts @@ -6,7 +6,6 @@ const updateInfoIncludeUpdater = { const draftContractRevisionsWithDraftRates = { stateContacts: true, - addtlActuaryContacts: true, contractDocuments: true, supportingDocuments: true, draftRates: { diff --git a/services/app-api/src/postgres/prismaTypes.ts b/services/app-api/src/postgres/prismaTypes.ts index 2988c8ae34..8e76e4fce6 100644 --- a/services/app-api/src/postgres/prismaTypes.ts +++ b/services/app-api/src/postgres/prismaTypes.ts @@ -1,5 +1,4 @@ import { - ActuaryContact, ContractDocument, ContractRevisionTable, ContractSupportingDocument, @@ -36,7 +35,6 @@ type ContractRevisionTableWithRelations = ContractRevisionTable & { submitInfo?: UpdateInfoTableWithUpdater | null unlockInfo?: UpdateInfoTableWithUpdater | null stateContacts: StateContact[] - addtlActuaryContacts: ActuaryContact[] contractDocuments: ContractDocument[] supportingDocuments: ContractSupportingDocument[] managedCareEntities: ManagedCareEntity[]