diff --git a/src/db/index.ts b/src/db/index.ts index 6dd0e197..18b2d2d7 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -71,6 +71,7 @@ import planLocation from './models/planLocation'; import planReportingPeriod from './models/planReportingPeriod'; import planTag from './models/planTag'; import planVersion from './models/planVersion'; +import planVersionOrganization from './models/planVersionOrganization'; import planYear from './models/planYear'; import procedureEntityPrototype from './models/procedureEntityPrototype'; import procedureSection from './models/procedureSection'; @@ -189,6 +190,7 @@ const initializeTables = (masterConn: Knex, replicaConn?: Knex) => ({ planReportingPeriod: planReportingPeriod(masterConn, replicaConn), planTag: planTag(masterConn, replicaConn), planVersion: planVersion(masterConn, replicaConn), + planVersionOrganization: planVersionOrganization(masterConn, replicaConn), planYear: planYear(masterConn, replicaConn), procedureEntityPrototype: procedureEntityPrototype(masterConn, replicaConn), procedureSection: procedureSection(masterConn, replicaConn), diff --git a/src/db/models/categoryGroup.ts b/src/db/models/categoryGroup.ts index 3571169a..d190b811 100644 --- a/src/db/models/categoryGroup.ts +++ b/src/db/models/categoryGroup.ts @@ -18,8 +18,10 @@ export const CATEGORY_GROUP_TYPE = t.keyof({ organizationLevel: null, organizationType: null, pendingStatus: null, + planClusterType: null, planCosting: null, planIndicated: null, + planLanguage: null, planType: null, projectGrouping1: null, projectGrouping2: null, diff --git a/src/db/models/plan.ts b/src/db/models/plan.ts index 16dab09b..fae97352 100644 --- a/src/db/models/plan.ts +++ b/src/db/models/plan.ts @@ -2,6 +2,7 @@ import * as t from 'io-ts'; import { brandedType } from '../../util/io-ts'; import type { Brand } from '../../util/types'; +import { DATE } from '../util/datatypes'; import { defineIDModel } from '../util/id-model'; export type PlanId = Brand; @@ -26,6 +27,10 @@ export default defineIDModel({ }, optional: { revisionState: { kind: 'checked', type: PLAN_REVISION_STATE }, + releasedDate: { kind: 'checked', type: DATE }, + }, + nonNullWithDefault: { + isReleased: { kind: 'checked', type: t.boolean }, }, }, idField: 'id', diff --git a/src/db/models/planVersion.ts b/src/db/models/planVersion.ts index dbd6f056..bfcd2d10 100644 --- a/src/db/models/planVersion.ts +++ b/src/db/models/planVersion.ts @@ -37,6 +37,7 @@ export default defineLegacyVersionedModel({ kind: 'checked', type: PLAN_VISIBILITY_PREFERENCES, }, + isPartOfGHO: { kind: 'checked', type: t.boolean }, }, required: { planId: { kind: 'branded-integer', brand: PLAN_ID }, @@ -57,6 +58,11 @@ export default defineLegacyVersionedModel({ kind: 'checked', type: PLAN_VERSION_CLUSTER_SELECTION_TYPE, }, + pdfPublishDate: { kind: 'checked', type: DATE }, + }, + accidentallyOptional: { + shortName: { kind: 'checked', type: t.string }, + subtitle: { kind: 'checked', type: t.string }, }, }, idField: 'id', diff --git a/src/db/models/planVersionOrganization.ts b/src/db/models/planVersionOrganization.ts new file mode 100644 index 00000000..985ba3c1 --- /dev/null +++ b/src/db/models/planVersionOrganization.ts @@ -0,0 +1,14 @@ +import { defineSequelizeModel } from '../util/sequelize-model'; +import { ORGANIZATION_ID } from './organization'; +import { PLAN_VERSION_ID } from './planVersion'; + +export default defineSequelizeModel({ + tableName: 'planVersionOrganization', + fields: { + required: { + organizationId: { kind: 'branded-integer', brand: ORGANIZATION_ID }, + planVersionId: { kind: 'branded-integer', brand: PLAN_VERSION_ID }, + }, + }, + softDeletionEnabled: false, +});