@kipicore/dbcore 1.1.528 → 1.1.530
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/db/psql/migrations/20260526103420-certificate_request.js +10 -0
- package/dist/db/psql/migrations/20260527062918-add_studentid_to_certificate_request.d.ts +2 -0
- package/dist/db/psql/migrations/20260527062918-add_studentid_to_certificate_request.js +21 -0
- package/dist/db/psql/migrations/20260527113000-fix_course_status_in_user_has_course.d.ts +2 -0
- package/dist/db/psql/migrations/20260527113000-fix_course_status_in_user_has_course.js +40 -0
- package/dist/interfaces/certificateRequestInterface.d.ts +1 -0
- package/dist/models/psql/certificateRequestModel.d.ts +1 -0
- package/dist/models/psql/certificateRequestModel.js +13 -0
- package/dist/models/psql/userHasCourseModel.js +1 -0
- package/package.json +1 -1
|
@@ -13,6 +13,11 @@ const up = async (queryInterface, Sequelize) => {
|
|
|
13
13
|
allowNull: false,
|
|
14
14
|
primaryKey: true,
|
|
15
15
|
},
|
|
16
|
+
studentId: {
|
|
17
|
+
type: Sequelize.UUID,
|
|
18
|
+
field: 'student_id',
|
|
19
|
+
allowNull: true,
|
|
20
|
+
},
|
|
16
21
|
certificateType: {
|
|
17
22
|
type: Sequelize.STRING,
|
|
18
23
|
field: 'certificate_type',
|
|
@@ -88,6 +93,11 @@ const up = async (queryInterface, Sequelize) => {
|
|
|
88
93
|
allowNull: false,
|
|
89
94
|
primaryKey: true,
|
|
90
95
|
},
|
|
96
|
+
studentId: {
|
|
97
|
+
type: Sequelize.UUID,
|
|
98
|
+
field: 'student_id',
|
|
99
|
+
allowNull: true,
|
|
100
|
+
},
|
|
91
101
|
certificateType: {
|
|
92
102
|
type: Sequelize.STRING,
|
|
93
103
|
field: 'certificate_type',
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const up = async (queryInterface, Sequelize) => {
|
|
3
|
+
const table = await queryInterface.describeTable('certificate_request');
|
|
4
|
+
if (!table.student_id) {
|
|
5
|
+
await queryInterface.addColumn('certificate_request', 'student_id', {
|
|
6
|
+
type: Sequelize.UUID,
|
|
7
|
+
allowNull: true,
|
|
8
|
+
field: 'student_id',
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const down = async (queryInterface) => {
|
|
13
|
+
const table = await queryInterface.describeTable('certificate_request');
|
|
14
|
+
if (table.student_id) {
|
|
15
|
+
await queryInterface.removeColumn('certificate_request', 'student_id');
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
module.exports = {
|
|
19
|
+
up,
|
|
20
|
+
down,
|
|
21
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const up = async (queryInterface, Sequelize) => {
|
|
3
|
+
const tableName = 'userHasUserHasCourses';
|
|
4
|
+
const table = await queryInterface.describeTable(tableName);
|
|
5
|
+
if (!table.course_status) {
|
|
6
|
+
await queryInterface.addColumn(tableName, 'course_status', {
|
|
7
|
+
type: Sequelize.STRING,
|
|
8
|
+
allowNull: true,
|
|
9
|
+
defaultValue: 'RUNNING',
|
|
10
|
+
field: 'course_status',
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
if (table.courseStatus) {
|
|
14
|
+
await queryInterface.sequelize.query(`UPDATE "${tableName}" SET "course_status" = COALESCE("course_status", "courseStatus") WHERE "courseStatus" IS NOT NULL;`);
|
|
15
|
+
await queryInterface.removeColumn(tableName, 'courseStatus');
|
|
16
|
+
}
|
|
17
|
+
if (table.user_has_course_status) {
|
|
18
|
+
await queryInterface.sequelize.query(`UPDATE "${tableName}" SET "course_status" = COALESCE("course_status", "user_has_course_status") WHERE "user_has_course_status" IS NOT NULL;`);
|
|
19
|
+
await queryInterface.removeColumn(tableName, 'user_has_course_status');
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const down = async (queryInterface, Sequelize) => {
|
|
23
|
+
const tableName = 'userHasUserHasCourses';
|
|
24
|
+
const table = await queryInterface.describeTable(tableName);
|
|
25
|
+
if (!table.courseStatus) {
|
|
26
|
+
await queryInterface.addColumn(tableName, 'courseStatus', {
|
|
27
|
+
type: Sequelize.STRING,
|
|
28
|
+
allowNull: true,
|
|
29
|
+
defaultValue: 'RUNNING',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (table.course_status) {
|
|
33
|
+
await queryInterface.sequelize.query(`UPDATE "${tableName}" SET "courseStatus" = COALESCE("courseStatus", "course_status") WHERE "course_status" IS NOT NULL;`);
|
|
34
|
+
await queryInterface.removeColumn(tableName, 'course_status');
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
module.exports = {
|
|
38
|
+
up,
|
|
39
|
+
down,
|
|
40
|
+
};
|
|
@@ -5,6 +5,7 @@ import { CERTIFICATE_REQUEST_STATUS, CERTIFICATE_REQUEST_TYPE } from '../../cons
|
|
|
5
5
|
declare class CertificateRequestModel extends Model<ICertificateRequestModelAttributes, TCertificateRequestCreationAttributes> {
|
|
6
6
|
id: string;
|
|
7
7
|
parentId: string;
|
|
8
|
+
studentId: string;
|
|
8
9
|
canceledBy: string;
|
|
9
10
|
completedBy: string;
|
|
10
11
|
instituteId?: string;
|
|
@@ -53,6 +53,14 @@ class CertificateRequestModel extends sequelize_1.Model {
|
|
|
53
53
|
foreignKey: { name: 'instituteId', field: 'institute_id' },
|
|
54
54
|
as: 'instituteCertificateR',
|
|
55
55
|
});
|
|
56
|
+
CertificateRequestModel.belongsTo(UserModel, {
|
|
57
|
+
foreignKey: { name: 'studentId', field: 'student_id' },
|
|
58
|
+
as: 'certificateRStudent',
|
|
59
|
+
});
|
|
60
|
+
UserModel.hasMany(CertificateRequestModel, {
|
|
61
|
+
foreignKey: { name: 'studentId', field: 'student_id' },
|
|
62
|
+
as: 'studentCertificateR',
|
|
63
|
+
});
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
66
|
CertificateRequestModel.init({
|
|
@@ -62,6 +70,11 @@ CertificateRequestModel.init({
|
|
|
62
70
|
allowNull: false,
|
|
63
71
|
primaryKey: true,
|
|
64
72
|
},
|
|
73
|
+
studentId: {
|
|
74
|
+
type: sequelize_1.DataTypes.UUID,
|
|
75
|
+
field: 'student_id',
|
|
76
|
+
allowNull: true,
|
|
77
|
+
},
|
|
65
78
|
certificateType: {
|
|
66
79
|
type: sequelize_1.DataTypes.STRING,
|
|
67
80
|
field: 'certificate_type',
|
package/package.json
CHANGED