Skip to content

Commit

Permalink
Merge branch 'wml-db-history' of https://github.com/Enterprise-CMCS/m…
Browse files Browse the repository at this point in the history
…anaged-care-review into mcr-4014-submission-submmary-v2
  • Loading branch information
pearl-truss committed Apr 15, 2024
2 parents c6516bf + 5b28925 commit 8d26735
Show file tree
Hide file tree
Showing 68 changed files with 1,827 additions and 1,151 deletions.
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;
2 changes: 1 addition & 1 deletion services/app-api/src/dataMigrations/_sampleTest.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sharedTestPrismaClient } from '../testHelpers/storeHelpers'
import { migrate } from './migrations/20231106200334_fix_empty_rates'
import { migrate } from './migrations/20231026123042_test_migrator_works'

/*
Demo of how to test a data migration - can run and test locally with this test.
Expand Down
7 changes: 0 additions & 7 deletions services/app-api/src/dataMigrations/dataMigrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { PrismaTransactionType } from '../postgres/prismaTypes'
import { migrate as migrate1 } from './migrations/20231026123042_test_migrator_works'
import { migrate as migrate2 } from './migrations/20231026124442_fix_rate_submittedat'
import { migrate as migrate3 } from './migrations/20231026124542_fix_erroneous_rates'
import { migrate as migrate4 } from './migrations/20231106200334_fix_empty_rates'

// MigrationType describes a single migration with a name and a callable function called migrateProto
interface DBMigrationType {
Expand Down Expand Up @@ -104,12 +103,6 @@ export async function migrate(
migrate: migrate3,
},
},
{
name: 'migrations/20231106200334_fix_empty_rates',
module: {
migrate: migrate4,
},
},
]
// for (const migrationFile of migrationFiles) {
// // const fullPath = './migrations/0001_test_migration'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const documentSchema = z.object({
name: z.string(),
s3URL: z.string(),
sha256: z.string(),
dateAdded: z.date().optional(), // date added to the first submission to CMS
})

const managedCareEntitiesSchema = z.union([
Expand Down Expand Up @@ -90,10 +91,19 @@ const rateFormDataSchema = z.object({
.optional(),
})

type DocumentType = z.infer<typeof documentSchema>
type ContractFormDataType = z.infer<typeof contractFormDataSchema>
type RateFormDataType = z.infer<typeof rateFormDataSchema>
type DocumentType = z.infer<typeof documentSchema>

type ContractFormEditableType = Partial<ContractFormDataType>
type RateFormEditableType = Partial<RateFormDataType>

export { contractFormDataSchema, rateFormDataSchema }

export type { ContractFormDataType, RateFormDataType, DocumentType }
export type {
ContractFormDataType,
RateFormDataType,
DocumentType,
RateFormEditableType,
ContractFormEditableType,
}
2 changes: 2 additions & 0 deletions services/app-api/src/domain-models/contractAndRates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export type {
ContractFormDataType,
RateFormDataType,
DocumentType,
RateFormEditableType,
ContractFormEditableType,
} from './formDataTypes'

export type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const formData: ContractFormDataType = {
s3URL: 'bar',
name: 'foo',
sha256: 'fakesha',
dateAdded: new Date(),
},
],
contractType: 'BASE',
Expand Down
8 changes: 5 additions & 3 deletions services/app-api/src/postgres/contractAndRates/insertRate.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { StateCodeType } from '../../../../app-web/src/common-code/healthPlanFormDataType'
import type { RateType } from '../../domain-models/contractAndRates'
import type {
RateFormEditableType,
RateType,
} from '../../domain-models/contractAndRates'
import { parseRateWithHistory } from './parseRateWithHistory'
import { includeFullRate } from './prismaSubmittedRateHelpers'
import type { PrismaClient } from '@prisma/client'
import type { RateFormEditable } from './updateDraftRate'

type InsertRateArgsType = RateFormEditable & {
type InsertRateArgsType = RateFormEditableType & {
stateCode: StateCodeType
}

Expand Down
Loading

0 comments on commit 8d26735

Please sign in to comment.