Skip to content

Commit

Permalink
Merge pull request #146 from UN-OCHA/HPC-9489
Browse files Browse the repository at this point in the history
HPC-9489: Creation of new datapoints attached to plans
  • Loading branch information
enxtur authored Sep 13, 2024
2 parents 6e22bf1 + 608e81c commit 3392165
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
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,
});

0 comments on commit 3392165

Please sign in to comment.