-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor prisma further #1891
Refactor prisma further #1891
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
BEGIN; | ||
/* | ||
Warnings: | ||
|
||
- You are about to drop the column `contractRevisionID` on the `ContractDocument` table. All the data in the column will be lost. | ||
- You are about to drop the column `rateRevisionID` on the `RateDocument` table. All the data in the column will be lost. | ||
- You are about to drop the `ContractSupportingDocument` table. If the table is not empty, all the data it contains will be lost. | ||
- You are about to drop the `RateSupportingDocument` table. If the table is not empty, all the data it contains will be lost. | ||
- Added the required column `contractDocumentRevisionID` to the `ContractDocument` table without a default value. This is not possible if the table is not empty. | ||
- Added the required column `supportingDocumentRevisionID` to the `ContractDocument` table without a default value. This is not possible if the table is not empty. | ||
- Added the required column `rateDocumentRevisionID` to the `RateDocument` table without a default value. This is not possible if the table is not empty. | ||
- Added the required column `supportingDocumentRevisionID` to the `RateDocument` table without a default value. This is not possible if the table is not empty. | ||
|
||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "ContractDocument" DROP CONSTRAINT "ContractDocument_contractRevisionID_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "ContractSupportingDocument" DROP CONSTRAINT "ContractSupportingDocument_contractRevisionID_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "RateDocument" DROP CONSTRAINT "RateDocument_rateRevisionID_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "RateSupportingDocument" DROP CONSTRAINT "RateSupportingDocument_rateRevisionID_fkey"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "ContractDocument" DROP COLUMN "contractRevisionID", | ||
ADD COLUMN "contractDocumentRevisionID" TEXT NOT NULL, | ||
ADD COLUMN "supportingDocumentRevisionID" TEXT NOT NULL; | ||
|
||
-- AlterTable | ||
ALTER TABLE "RateDocument" DROP COLUMN "rateRevisionID", | ||
ADD COLUMN "rateDocumentRevisionID" TEXT NOT NULL, | ||
ADD COLUMN "supportingDocumentRevisionID" TEXT NOT NULL; | ||
|
||
-- DropTable | ||
DROP TABLE "ContractSupportingDocument"; | ||
|
||
-- DropTable | ||
DROP TABLE "RateSupportingDocument"; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ContractDocument" ADD CONSTRAINT "ContractDocument_contractDocumentRevisionID_fkey" FOREIGN KEY ("contractDocumentRevisionID") REFERENCES "ContractRevisionTable"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ContractDocument" ADD CONSTRAINT "ContractDocument_supportingDocumentRevisionID_fkey" FOREIGN KEY ("supportingDocumentRevisionID") REFERENCES "ContractRevisionTable"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "RateDocument" ADD CONSTRAINT "RateDocument_rateDocumentRevisionID_fkey" FOREIGN KEY ("rateDocumentRevisionID") REFERENCES "RateRevisionTable"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "RateDocument" ADD CONSTRAINT "RateDocument_supportingDocumentRevisionID_fkey" FOREIGN KEY ("supportingDocumentRevisionID") REFERENCES "RateRevisionTable"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
COMMIT; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
BEGIN; | ||
-- AlterTable | ||
ALTER TABLE "ActuaryContact" ADD COLUMN "display_seq" INTEGER; | ||
|
||
-- AlterTable | ||
ALTER TABLE "ContractDocument" ADD COLUMN "display_seq" INTEGER; | ||
|
||
-- AlterTable | ||
ALTER TABLE "RateDocument" ADD COLUMN "display_seq" INTEGER; | ||
|
||
-- AlterTable | ||
ALTER TABLE "StateContact" ADD COLUMN "display_seq" INTEGER; | ||
COMMIT; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,60 +35,60 @@ model HealthPlanRevisionTable { | |
} | ||
|
||
model ContractTable { | ||
id String @id @default(uuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @default(now()) @updatedAt | ||
id String @id @default(uuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @default(now()) @updatedAt | ||
|
||
stateCode String | ||
state State @relation(fields: [stateCode], references: [stateCode]) | ||
stateNumber Int | ||
stateCode String | ||
state State @relation(fields: [stateCode], references: [stateCode]) | ||
stateNumber Int | ||
|
||
revisions ContractRevisionTable[] | ||
draftRateRevisions RateRevisionTable[] | ||
} | ||
|
||
model RateTable { | ||
id String @id @default(uuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @default(now()) @updatedAt | ||
id String @id @default(uuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @default(now()) @updatedAt | ||
|
||
stateCode String | ||
state State @relation(fields: [stateCode], references: [stateCode]) | ||
stateNumber Int | ||
stateCode String | ||
state State @relation(fields: [stateCode], references: [stateCode]) | ||
stateNumber Int | ||
|
||
revisions RateRevisionTable[] | ||
draftContractRevisions ContractRevisionTable[] | ||
} | ||
|
||
model ContractRevisionTable { | ||
id String @id @default(uuid()) | ||
contractID String | ||
contract ContractTable @relation(fields: [contractID], references: [id]) | ||
id String @id @default(uuid()) | ||
contractID String | ||
contract ContractTable @relation(fields: [contractID], references: [id]) | ||
|
||
rateRevisions RateRevisionsOnContractRevisionsTable[] | ||
sharedRateRevisions SharedRateCertifications[] | ||
draftRates RateTable[] | ||
rateRevisions RateRevisionsOnContractRevisionsTable[] | ||
sharedRateRevisions SharedRateCertifications[] | ||
draftRates RateTable[] | ||
|
||
unlockInfoID String? | ||
unlockInfo UpdateInfoTable? @relation("unlockContractInfo", fields: [unlockInfoID], references: [id]) | ||
submitInfoID String? | ||
submitInfo UpdateInfoTable? @relation("submitContractInfo", fields: [submitInfoID], references: [id]) | ||
unlockInfoID String? | ||
unlockInfo UpdateInfoTable? @relation("unlockContractInfo", fields: [unlockInfoID], references: [id]) | ||
submitInfoID String? | ||
submitInfo UpdateInfoTable? @relation("submitContractInfo", fields: [submitInfoID], references: [id]) | ||
|
||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @default(now()) @updatedAt | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @default(now()) @updatedAt | ||
|
||
submissionType SubmissionType | ||
submissionDescription String | ||
programIDs String[] | ||
populationCovered PopulationCoverageType? | ||
riskBasedContract Boolean? | ||
stateContacts StateContact[] | ||
supportingDocuments ContractSupportingDocument[] | ||
contractType ContractType | ||
contractExecutionStatus ContractExecutionStatus? | ||
contractDocuments ContractDocument[] | ||
contractDateStart DateTime? @db.Date | ||
contractDateEnd DateTime? @db.Date | ||
contractDocuments ContractDocument[] @relation(name: "ContractDocumentOnContractRevision") | ||
supportingDocuments ContractDocument[] @relation(name: "SupportingDocumentOnContractRevision") | ||
contractDateStart DateTime? @db.Date | ||
contractDateEnd DateTime? @db.Date | ||
managedCareEntities ManagedCareEntity[] | ||
federalAuthorities FederalAuthority[] | ||
modifiedBenefitsProvided Boolean? | ||
|
@@ -111,32 +111,32 @@ model ContractRevisionTable { | |
} | ||
|
||
model RateRevisionTable { | ||
id String @id @default(uuid()) | ||
rateID String | ||
rate RateTable @relation(fields: [rateID], references: [id]) | ||
contractRevisions RateRevisionsOnContractRevisionsTable[] | ||
draftContracts ContractTable[] | ||
|
||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @default(now()) @updatedAt | ||
unlockInfoID String? | ||
unlockInfo UpdateInfoTable? @relation("unlockRateInfo", fields: [unlockInfoID], references: [id]) | ||
submitInfoID String? | ||
submitInfo UpdateInfoTable? @relation("submitRateInfo", fields: [submitInfoID], references: [id]) | ||
id String @id @default(uuid()) | ||
rateID String | ||
rate RateTable @relation(fields: [rateID], references: [id]) | ||
contractRevisions RateRevisionsOnContractRevisionsTable[] | ||
draftContracts ContractTable[] | ||
|
||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @default(now()) @updatedAt | ||
unlockInfoID String? | ||
unlockInfo UpdateInfoTable? @relation("unlockRateInfo", fields: [unlockInfoID], references: [id]) | ||
submitInfoID String? | ||
submitInfo UpdateInfoTable? @relation("submitRateInfo", fields: [submitInfoID], references: [id]) | ||
|
||
rateType RateType? | ||
rateCapitationType RateCapitationType? | ||
rateDocuments RateDocument[] | ||
supportingDocuments RateSupportingDocument[] | ||
rateDateStart DateTime? @db.Date | ||
rateDateEnd DateTime? @db.Date | ||
rateDateCertified DateTime? @db.Date | ||
amendmentEffectiveDateStart DateTime? @db.Date | ||
amendmentEffectiveDateEnd DateTime? @db.Date | ||
rateDocuments RateDocument[] @relation(name: "RateDocumentOnRateRevision") | ||
supportingDocuments RateDocument[] @relation(name: "SupportingDocumentOnRateRevision") | ||
rateDateStart DateTime? @db.Date | ||
rateDateEnd DateTime? @db.Date | ||
rateDateCertified DateTime? @db.Date | ||
amendmentEffectiveDateStart DateTime? @db.Date | ||
amendmentEffectiveDateEnd DateTime? @db.Date | ||
rateProgramIDs String[] | ||
rateCertificationName String? | ||
certifyingActuaryContacts ActuaryContact[] @relation(name: "CertifyingActuaryOnRateRevision") | ||
addtlActuaryContacts ActuaryContact[] @relation(name: "AddtlActuaryOnRateRevision") | ||
certifyingActuaryContacts ActuaryContact[] @relation(name: "CertifyingActuaryOnRateRevision") | ||
addtlActuaryContacts ActuaryContact[] @relation(name: "AddtlActuaryOnRateRevision") | ||
actuaryCommunicationPreference ActuaryCommunication? | ||
packagesWithSharedRateCerts SharedRateCertifications[] | ||
} | ||
|
@@ -155,15 +155,15 @@ model RateRevisionsOnContractRevisionsTable { | |
} | ||
|
||
model UpdateInfoTable { | ||
id String @id @default(uuid()) | ||
updatedAt DateTime | ||
updatedByID String | ||
updatedBy User @relation(fields: [updatedByID], references: [id]) | ||
updatedReason String | ||
unlockedContracts ContractRevisionTable[] @relation("unlockContractInfo") | ||
id String @id @default(uuid()) | ||
updatedAt DateTime | ||
updatedByID String | ||
updatedBy User @relation(fields: [updatedByID], references: [id]) | ||
updatedReason String | ||
unlockedContracts ContractRevisionTable[] @relation("unlockContractInfo") | ||
submittedContracts ContractRevisionTable[] @relation("submitContractInfo") | ||
unlockedRates RateRevisionTable[] @relation("unlockRateInfo") | ||
submittedRates RateRevisionTable[] @relation("submitRateInfo") | ||
unlockedRates RateRevisionTable[] @relation("unlockRateInfo") | ||
submittedRates RateRevisionTable[] @relation("submitRateInfo") | ||
} | ||
|
||
model SharedRateCertifications { | ||
|
@@ -175,62 +175,47 @@ model SharedRateCertifications { | |
} | ||
|
||
model ActuaryContact { | ||
id String @id @default(uuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @default(now()) @updatedAt | ||
name String? | ||
titleRole String? | ||
email String? | ||
actuarialFirm ActuarialFirm? | ||
actuarialFirmOther String? | ||
rateWithCertifyingActuaryID String? | ||
rateWithAddtlActuaryID String? | ||
rateActuaryCertifying RateRevisionTable? @relation(name: "CertifyingActuaryOnRateRevision", fields: [ rateWithCertifyingActuaryID ], references: [id]) | ||
rateActuaryAddtl RateRevisionTable? @relation(name: "AddtlActuaryOnRateRevision", fields: [ rateWithAddtlActuaryID ], references: [id]) | ||
id String @id @default(uuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @default(now()) @updatedAt | ||
name String? | ||
titleRole String? | ||
email String? | ||
actuarialFirm ActuarialFirm? | ||
actuarialFirmOther String? | ||
rateWithCertifyingActuaryID String? | ||
rateWithAddtlActuaryID String? | ||
rateActuaryCertifying RateRevisionTable? @relation(name: "CertifyingActuaryOnRateRevision", fields: [rateWithCertifyingActuaryID], references: [id]) | ||
rateActuaryAddtl RateRevisionTable? @relation(name: "AddtlActuaryOnRateRevision", fields: [rateWithAddtlActuaryID], references: [id]) | ||
display_seq Int? | ||
} | ||
|
||
model ContractDocument { | ||
id String @id @default(uuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @default(now()) @updatedAt | ||
name String | ||
s3URL String | ||
sha256 String | ||
contractRevisionID String | ||
contractRevision ContractRevisionTable @relation(fields: [contractRevisionID], references: [id]) | ||
} | ||
|
||
model ContractSupportingDocument { | ||
id String @id @default(uuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @default(now()) @updatedAt | ||
name String | ||
s3URL String | ||
sha256 String | ||
contractRevisionID String | ||
contractRevision ContractRevisionTable @relation(fields: [contractRevisionID], references: [id]) | ||
id String @id @default(uuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @default(now()) @updatedAt | ||
name String | ||
s3URL String | ||
sha256 String | ||
contractDocumentRevisionID String | ||
supportingDocumentRevisionID String | ||
contractDocumentContractRevision ContractRevisionTable? @relation(name: "ContractDocumentOnContractRevision", fields: [contractDocumentRevisionID], references: [id]) | ||
supportingDocumentContractRevision ContractRevisionTable? @relation(name: "SupportingDocumentOnContractRevision", fields: [supportingDocumentRevisionID], references: [id]) | ||
display_seq Int? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems a bit dodgy to have this be optional, when would we not want to set it? I think all of these things need to have a visual order every time There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @macrael The reason i didn't set this is we haven't discussed when and how it gets set. I was just adding it in to be used in the future since we discussed it in slack. Is it set in handlers I'm guessing - so on create or update prisma actions? And then we start to |
||
} | ||
|
||
model RateDocument { | ||
id String @id @default(uuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @default(now()) @updatedAt | ||
name String | ||
s3URL String | ||
sha256 String | ||
rateRevisionID String | ||
rateRevision RateRevisionTable @relation(fields: [rateRevisionID], references: [id]) | ||
} | ||
|
||
model RateSupportingDocument { | ||
id String @id @default(uuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @default(now()) @updatedAt | ||
name String | ||
s3URL String | ||
sha256 String | ||
rateRevisionID String | ||
rateRevision RateRevisionTable @relation(fields: [rateRevisionID], references: [id]) | ||
id String @id @default(uuid()) | ||
createdAt DateTime @default(now()) | ||
updatedAt DateTime @default(now()) @updatedAt | ||
name String | ||
s3URL String | ||
sha256 String | ||
rateDocumentRevisionID String | ||
supportingDocumentRevisionID String | ||
ratetDocumentContractRevision RateRevisionTable? @relation(name: "RateDocumentOnRateRevision", fields: [rateDocumentRevisionID], references: [id]) | ||
supportingDocumentContractRevision RateRevisionTable? @relation(name: "SupportingDocumentOnRateRevision", fields: [supportingDocumentRevisionID], references: [id]) | ||
display_seq Int? | ||
} | ||
|
||
model StateContact { | ||
|
@@ -242,6 +227,7 @@ model StateContact { | |
email String? | ||
contractRevisionID String | ||
contractRevision ContractRevisionTable @relation(fields: [contractRevisionID], references: [id]) | ||
display_seq Int? | ||
} | ||
|
||
model State { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to do it this way, why not have a single documents table?
The reason I suggested we have 4 different tables here was that then the primary key could be required in the database, ensuring that we don't accidentally orphan a document at some point. But I don't think that's that big a deal, it would be nice if we could add a db constraint that made sure that one of the four primary keys were set so you can't make a document that doesn't belong to anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@macrael Gotcha, I am understanding you now. I might be missing something about how relations work let me know. I will keep looking around for a way to implement that type of constraint at the db layer.