Skip to content

Commit 518fa1c

Browse files
committed
🗃️ Define planYear model
1 parent d15aee2 commit 518fa1c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/db/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import plan from './models/plan';
2323
import planEntity from './models/planEntity';
2424
import planEntityVersion from './models/planEntityVersion';
2525
import planVersion from './models/planVersion';
26+
import planYear from './models/planYear';
2627
import projectVersion from './models/projectVersion';
2728
import projectVersionAttachment from './models/projectVersionAttachment';
2829
import projectVersionPlan from './models/projectVersionPlan';
@@ -54,6 +55,7 @@ export default (conn: Knex) => ({
5455
planEntity: planEntity(conn),
5556
planEntityVersion: planEntityVersion(conn),
5657
planVersion: planVersion(conn),
58+
planYear: planYear(conn),
5759
project: project(conn),
5860
projectVersion: projectVersion(conn),
5961
projectVersionAttachment: projectVersionAttachment(conn),

src/db/models/planYear.ts

+18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import * as t from 'io-ts';
22

33
import { brandedType } from '../../util/io-ts';
44
import type { Brand } from '../../util/types';
5+
import { defineLegacyVersionedModel } from '../util/legacy-versioned-model';
6+
import { PLAN_ID } from './plan';
7+
import { USAGE_YEAR_ID } from './usageYear';
58

69
export type PlanYearId = Brand<
710
number,
@@ -10,3 +13,18 @@ export type PlanYearId = Brand<
1013
>;
1114

1215
export const PLAN_YEAR_ID = brandedType<number, PlanYearId>(t.number);
16+
17+
export default defineLegacyVersionedModel({
18+
tableName: 'planYear',
19+
fields: {
20+
generated: {
21+
id: { kind: 'branded-integer', brand: PLAN_YEAR_ID },
22+
},
23+
required: {
24+
planId: { kind: 'branded-integer', brand: PLAN_ID },
25+
usageYearId: { kind: 'branded-integer', brand: USAGE_YEAR_ID },
26+
},
27+
},
28+
idField: 'id',
29+
softDeletionEnabled: true,
30+
});

0 commit comments

Comments
 (0)