@@ -2,6 +2,10 @@ import * as t from 'io-ts';
2
2
3
3
import { brandedType } from '../../util/io-ts' ;
4
4
import type { Brand } from '../../util/types' ;
5
+ import { DATE } from '../util/datatypes' ;
6
+ import { defineLegacyVersionedModel } from '../util/legacy-versioned-model' ;
7
+ import { PLAN_ID } from './plan' ;
8
+ import { PLAN_REPORTING_PERIOD_ID } from './planReportingPeriod' ;
5
9
6
10
export type PlanVersionId = Brand <
7
11
number ,
@@ -10,3 +14,43 @@ export type PlanVersionId = Brand<
10
14
> ;
11
15
12
16
export const PLAN_VERSION_ID = brandedType < number , PlanVersionId > ( t . number ) ;
17
+
18
+ const PLAN_VERSION_CLUSTER_SELECTION_TYPE = {
19
+ single : null ,
20
+ multi : null ,
21
+ } ;
22
+
23
+ export default defineLegacyVersionedModel ( {
24
+ tableName : 'planVersion' ,
25
+ fields : {
26
+ generated : {
27
+ id : { kind : 'branded-integer' , brand : PLAN_VERSION_ID } ,
28
+ } ,
29
+ nonNullWithDefault : {
30
+ isForHPCProjects : { kind : 'checked' , type : t . boolean } ,
31
+ } ,
32
+ accidentallyOptional : {
33
+ planId : { kind : 'branded-integer' , brand : PLAN_ID } ,
34
+ name : { kind : 'checked' , type : t . string } ,
35
+ startDate : { kind : 'checked' , type : DATE } ,
36
+ endDate : { kind : 'checked' , type : DATE } ,
37
+ } ,
38
+ optional : {
39
+ comments : { kind : 'checked' , type : t . string } ,
40
+ code : { kind : 'checked' , type : t . string } ,
41
+ customLocationCode : { kind : 'checked' , type : t . string } ,
42
+ currentReportingPeriodId : {
43
+ kind : 'branded-integer' ,
44
+ brand : PLAN_REPORTING_PERIOD_ID ,
45
+ } ,
46
+ lastPublishedReportingPeriodId : { kind : 'checked' , type : t . number } ,
47
+ // Even though this column isn't defined using DB enum only two values are used
48
+ clusterSelectionType : {
49
+ kind : 'enum' ,
50
+ values : PLAN_VERSION_CLUSTER_SELECTION_TYPE ,
51
+ } ,
52
+ } ,
53
+ } ,
54
+ idField : 'id' ,
55
+ softDeletionEnabled : false ,
56
+ } ) ;
0 commit comments