Skip to content

Commit

Permalink
🗃️ Define planYear model
Browse files Browse the repository at this point in the history
  • Loading branch information
Pl217 committed Nov 2, 2021
1 parent d15aee2 commit 518fa1c
Show file tree
Hide file tree
Showing 2 changed files with 20 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 @@ -23,6 +23,7 @@ import plan from './models/plan';
import planEntity from './models/planEntity';
import planEntityVersion from './models/planEntityVersion';
import planVersion from './models/planVersion';
import planYear from './models/planYear';
import projectVersion from './models/projectVersion';
import projectVersionAttachment from './models/projectVersionAttachment';
import projectVersionPlan from './models/projectVersionPlan';
Expand Down Expand Up @@ -54,6 +55,7 @@ export default (conn: Knex) => ({
planEntity: planEntity(conn),
planEntityVersion: planEntityVersion(conn),
planVersion: planVersion(conn),
planYear: planYear(conn),
project: project(conn),
projectVersion: projectVersion(conn),
projectVersionAttachment: projectVersionAttachment(conn),
Expand Down
18 changes: 18 additions & 0 deletions src/db/models/planYear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import * as t from 'io-ts';

import { brandedType } from '../../util/io-ts';
import type { Brand } from '../../util/types';
import { defineLegacyVersionedModel } from '../util/legacy-versioned-model';
import { PLAN_ID } from './plan';
import { USAGE_YEAR_ID } from './usageYear';

export type PlanYearId = Brand<
number,
Expand All @@ -10,3 +13,18 @@ export type PlanYearId = Brand<
>;

export const PLAN_YEAR_ID = brandedType<number, PlanYearId>(t.number);

export default defineLegacyVersionedModel({
tableName: 'planYear',
fields: {
generated: {
id: { kind: 'branded-integer', brand: PLAN_YEAR_ID },
},
required: {
planId: { kind: 'branded-integer', brand: PLAN_ID },
usageYearId: { kind: 'branded-integer', brand: USAGE_YEAR_ID },
},
},
idField: 'id',
softDeletionEnabled: true,
});

0 comments on commit 518fa1c

Please sign in to comment.