Skip to content

Commit fd14185

Browse files
flowState is saved to db
1 parent 9d37091 commit fd14185

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

src/common/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export type CourseRealization = {
112112
endDate: Date
113113
customCodeUrns: Record<string, string[]>
114114
courseUnitRealisationTypeUrn: string
115+
flowState: string
115116

116117
}
117118

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
import { DataTypes } from 'sequelize'
3+
4+
import { type Migration } from '../connection.ts'
5+
6+
export const up: Migration = async ({ context: queryInterface }) => {
7+
await queryInterface.addColumn('curs','flow_state', {
8+
type: string,
9+
allowNull: true
10+
})
11+
12+
}
13+
14+
export const down: Migration = async ({ context: queryInterface }) => {
15+
await queryInterface.removeColumn('curs', 'flow_state')
16+
}
17+

src/server/db/models/cur.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Cur extends Model<InferAttributes<Cur>, InferCreationAttributes<Cur>> {
1414
declare endDate: Date
1515
declare courseUnitRealisationTypeUrn: string
1616
declare customCodeUrns: Record<string, string[]>
17+
declare flowState: CreationOptional<string>
1718
declare createdAt: CreationOptional<Date>
1819
declare updatedAt: CreationOptional<Date>
1920
}
@@ -48,6 +49,10 @@ Cur.init(
4849
type: DataTypes.STRING,
4950
allowNull: true
5051
},
52+
flowState: {
53+
type: DataTypes.STRING,
54+
allowNull: true
55+
},
5156
createdAt: {
5257
type: DataTypes.DATE,
5358
allowNull: false,

src/server/updater/courses.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const createCursFromUpdater = async (
1212
realisations: SisuCourseWithRealization[]
1313
) => {
1414
const curs: CourseRealization[] = realisations.map((realisation) => {
15-
const { id, name, nameSpecifier, activityPeriod, customCodeUrns, courseUnitRealisationTypeUrn } = realisation
15+
const { id, name, nameSpecifier, activityPeriod, customCodeUrns, courseUnitRealisationTypeUrn, flowState } = realisation
1616
const startDate = new Date(activityPeriod.startDate)
1717
const endDate = new Date(activityPeriod.endDate)
1818
return {
@@ -21,6 +21,7 @@ const createCursFromUpdater = async (
2121
customCodeUrns,
2222
courseUnitRealisationTypeUrn,
2323
nameSpecifier,
24+
flowState,
2425
startDate,
2526
endDate,
2627
}

0 commit comments

Comments
 (0)