Skip to content
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

HPC-9489: Creation of new datapoints attached to plans #146

Merged
merged 5 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions src/db/models/categoryGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/db/models/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number, { readonly s: unique symbol }, 'plan.id'>;
Expand All @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions src/db/models/planVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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',
Expand Down
14 changes: 14 additions & 0 deletions src/db/models/planVersionOrganization.ts
Original file line number Diff line number Diff line change
@@ -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,
});