Skip to content

Commit 79dcf66

Browse files
committed
Add course type to chatInstances table, update it as part of updater runs
1 parent b7f67b3 commit 79dcf66

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

src/client/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export interface ChatInstance {
4242
resetCron?: string
4343
courseId?: string
4444
prompts: Prompt[]
45+
courseUnitRealisationTypeUrn?: string
4546
}
4647

4748
export interface AccessGroup {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { DataTypes } from 'sequelize'
2+
3+
import { Migration } from '../connection'
4+
5+
export const up: Migration = async ({ context: queryInterface }) => {
6+
await queryInterface.addColumn(
7+
'chat_instances',
8+
'course_unit_realisation_type_urn',
9+
{
10+
type: DataTypes.STRING,
11+
allowNull: true,
12+
defaultValue: null,
13+
}
14+
)
15+
}
16+
17+
export const down: Migration = async ({ context: queryInterface }) => {
18+
await queryInterface.removeColumn(
19+
'chat_instances',
20+
'course_unit_realisation_type_urn'
21+
)
22+
}

src/server/db/models/chatInstance.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class ChatInstance extends Model<
2828
declare courseId: string | null
2929

3030
declare activityPeriod: ActivityPeriod | null
31+
32+
declare courseUnitRealisationTypeUrn: string | null
3133
}
3234

3335
ChatInstance.init(
@@ -72,6 +74,11 @@ ChatInstance.init(
7274
allowNull: true,
7375
defaultValue: null,
7476
},
77+
courseUnitRealisationTypeUrn: {
78+
type: DataTypes.STRING,
79+
allowNull: true,
80+
defaultValue: null,
81+
},
7582
},
7683
{
7784
underscored: true,

src/server/updater/courses.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const createChatInstance = async (
5252
},
5353
courseId: course.id,
5454
activityPeriod: course.activityPeriod,
55+
courseUnitRealisationTypeUrn: course.courseUnitRealisationTypeUrn,
5556
}
5657
})
5758

@@ -65,8 +66,8 @@ const createChatInstance = async (
6566
conflictAttributes: ['courseId'],
6667
},
6768
fallbackCreateOptions: {
68-
fields: ['courseId']
69-
}
69+
fields: ['courseId'],
70+
},
7071
})
7172
}
7273

0 commit comments

Comments
 (0)