Skip to content

Commit

Permalink
🗃️ Define usageYear model
Browse files Browse the repository at this point in the history
  • Loading branch information
Pl217 committed Nov 2, 2021
1 parent 518fa1c commit 1c8157c
Show file tree
Hide file tree
Showing 2 changed files with 17 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 @@ -29,6 +29,7 @@ import projectVersionAttachment from './models/projectVersionAttachment';
import projectVersionPlan from './models/projectVersionPlan';
import reportingWindow from './models/reportingWindow';
import reportingWindowAssignment from './models/reportingWindowAssignment';
import usageYear from './models/usageYear';
import workflowStatusOption from './models/workflowStatusOption';

export default (conn: Knex) => ({
Expand Down Expand Up @@ -62,5 +63,6 @@ export default (conn: Knex) => ({
projectVersionPlan: projectVersionPlan(conn),
reportingWindow: reportingWindow(conn),
reportingWindowAssignment: reportingWindowAssignment(conn),
usageYear: usageYear(conn),
workflowStatusOption: workflowStatusOption(conn),
});
15 changes: 15 additions & 0 deletions src/db/models/usageYear.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 { defineIDModel } from '../util/id-model';

export type UsageYearId = Brand<
number,
Expand All @@ -10,3 +11,17 @@ export type UsageYearId = Brand<
>;

export const USAGE_YEAR_ID = brandedType<number, UsageYearId>(t.number);

export default defineIDModel({
tableName: 'usageYear',
fields: {
generated: {
id: { kind: 'branded-integer', brand: USAGE_YEAR_ID },
},
required: {
year: { kind: 'checked', type: t.string },
},
},
idField: 'id',
softDeletionEnabled: false,
});

0 comments on commit 1c8157c

Please sign in to comment.