-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into mcr-3988-fix
- Loading branch information
Showing
73 changed files
with
4,433 additions
and
2,178 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
services/app-api/prisma/migrations/20240401220251_add_package_join_table/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
BEGIN; | ||
-- DropEnum | ||
DROP TYPE "DocumentCategory"; | ||
|
||
-- CreateTable | ||
CREATE TABLE "SubmissionPackageJoinTable" ( | ||
"submissionID" TEXT NOT NULL, | ||
"contractRevisionID" TEXT NOT NULL, | ||
"rateRevisionID" TEXT NOT NULL, | ||
"ratePosition" INTEGER NOT NULL, | ||
|
||
CONSTRAINT "SubmissionPackageJoinTable_pkey" PRIMARY KEY ("submissionID","contractRevisionID","rateRevisionID") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "_ContractRevisionTableToUpdateInfoTable" ( | ||
"A" TEXT NOT NULL, | ||
"B" TEXT NOT NULL | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "_RateRevisionTableToUpdateInfoTable" ( | ||
"A" TEXT NOT NULL, | ||
"B" TEXT NOT NULL | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "_ContractRevisionTableToUpdateInfoTable_AB_unique" ON "_ContractRevisionTableToUpdateInfoTable"("A", "B"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "_ContractRevisionTableToUpdateInfoTable_B_index" ON "_ContractRevisionTableToUpdateInfoTable"("B"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "_RateRevisionTableToUpdateInfoTable_AB_unique" ON "_RateRevisionTableToUpdateInfoTable"("A", "B"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "_RateRevisionTableToUpdateInfoTable_B_index" ON "_RateRevisionTableToUpdateInfoTable"("B"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "SubmissionPackageJoinTable" ADD CONSTRAINT "SubmissionPackageJoinTable_submissionID_fkey" FOREIGN KEY ("submissionID") REFERENCES "UpdateInfoTable"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "SubmissionPackageJoinTable" ADD CONSTRAINT "SubmissionPackageJoinTable_contractRevisionID_fkey" FOREIGN KEY ("contractRevisionID") REFERENCES "ContractRevisionTable"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "SubmissionPackageJoinTable" ADD CONSTRAINT "SubmissionPackageJoinTable_rateRevisionID_fkey" FOREIGN KEY ("rateRevisionID") REFERENCES "RateRevisionTable"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_ContractRevisionTableToUpdateInfoTable" ADD CONSTRAINT "_ContractRevisionTableToUpdateInfoTable_A_fkey" FOREIGN KEY ("A") REFERENCES "ContractRevisionTable"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_ContractRevisionTableToUpdateInfoTable" ADD CONSTRAINT "_ContractRevisionTableToUpdateInfoTable_B_fkey" FOREIGN KEY ("B") REFERENCES "UpdateInfoTable"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_RateRevisionTableToUpdateInfoTable" ADD CONSTRAINT "_RateRevisionTableToUpdateInfoTable_A_fkey" FOREIGN KEY ("A") REFERENCES "RateRevisionTable"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_RateRevisionTableToUpdateInfoTable" ADD CONSTRAINT "_RateRevisionTableToUpdateInfoTable_B_fkey" FOREIGN KEY ("B") REFERENCES "UpdateInfoTable"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
COMMIT; |
17 changes: 17 additions & 0 deletions
17
services/app-api/prisma/migrations/20240401231337_add_draft_rate_join_table/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
BEGIN; | ||
-- CreateTable | ||
CREATE TABLE "DraftRateJoinTable" ( | ||
"contractID" TEXT NOT NULL, | ||
"rateID" TEXT NOT NULL, | ||
"ratePosition" INTEGER NOT NULL, | ||
|
||
CONSTRAINT "DraftRateJoinTable_pkey" PRIMARY KEY ("contractID","rateID") | ||
); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "DraftRateJoinTable" ADD CONSTRAINT "DraftRateJoinTable_contractID_fkey" FOREIGN KEY ("contractID") REFERENCES "ContractTable"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "DraftRateJoinTable" ADD CONSTRAINT "DraftRateJoinTable_rateID_fkey" FOREIGN KEY ("rateID") REFERENCES "RateTable"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
COMMIT; |
7 changes: 7 additions & 0 deletions
7
services/app-api/prisma/migrations/20240404083919_cascade_rate_joins/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
BEGIN; | ||
-- DropForeignKey | ||
ALTER TABLE "DraftRateJoinTable" DROP CONSTRAINT "DraftRateJoinTable_rateID_fkey"; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "DraftRateJoinTable" ADD CONSTRAINT "DraftRateJoinTable_rateID_fkey" FOREIGN KEY ("rateID") REFERENCES "RateTable"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
COMMIT; |
14 changes: 14 additions & 0 deletions
14
services/app-api/prisma/migrations/20240410060149_migrate_draft_rates/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
BEGIN; | ||
-- This migration finds all draft contract and rate revisions and makes entries in | ||
-- the DraftRateJoinTable, with their order defined by RANK | ||
INSERT INTO "DraftRateJoinTable" ("contractID", "rateID", "ratePosition") | ||
SELECT "ContractRevisionTable"."contractID", "RateRevisionTable"."rateID", RANK() OVER ( | ||
PARTITION BY "ContractRevisionTable".id | ||
ORDER BY "RateRevisionTable"."createdAt" DESC | ||
) from "ContractRevisionTable", "_ContractRevisionTableToRateTable", "RateRevisionTable" WHERE | ||
"ContractRevisionTable".id = "_ContractRevisionTableToRateTable"."A" AND | ||
"_ContractRevisionTableToRateTable"."B" = "RateRevisionTable"."rateID" AND | ||
"RateRevisionTable"."submitInfoID" IS NULL AND | ||
"ContractRevisionTable"."submitInfoID" IS NULL | ||
ON CONFLICT DO NOTHING; | ||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 0 additions & 66 deletions
66
services/app-api/src/dataMigrations/migrations/20231106200334_fix_empty_rates.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
services/app-api/src/domain-models/contractAndRates/packageSubmissions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { z } from 'zod' | ||
import { contractRevisionSchema, rateRevisionSchema } from './revisionTypes' | ||
import { updateInfoSchema } from './updateInfoType' | ||
|
||
const contractPackageSubmissionSchema = z.object({ | ||
submitInfo: updateInfoSchema, | ||
submittedRevisions: z.array( | ||
z.union([contractRevisionSchema, rateRevisionSchema]) | ||
), | ||
contractRevision: contractRevisionSchema, | ||
rateRevisions: z.array(rateRevisionSchema), | ||
}) | ||
|
||
const packgeSubmissionCause = z.union([ | ||
z.literal('CONTRACT_SUBMISSION'), | ||
z.literal('RATE_SUBMISSION'), | ||
z.literal('RATE_UNLINK'), | ||
z.literal('RATE_LINK'), | ||
]) | ||
|
||
const contractPackageSubmissionWithCauseSchema = | ||
contractPackageSubmissionSchema.extend({ | ||
cause: packgeSubmissionCause, | ||
}) | ||
|
||
type ContractPackageSubmissionType = z.infer< | ||
typeof contractPackageSubmissionSchema | ||
> | ||
|
||
type ContractPackageSubmissionWithCauseType = z.infer< | ||
typeof contractPackageSubmissionWithCauseSchema | ||
> | ||
|
||
export { | ||
contractPackageSubmissionSchema, | ||
contractPackageSubmissionWithCauseSchema, | ||
} | ||
|
||
export type { | ||
ContractPackageSubmissionType, | ||
ContractPackageSubmissionWithCauseType, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.