@kipicore/dbcore 1.1.529 → 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.
@@ -0,0 +1,2 @@
1
+ export function up(queryInterface: any, Sequelize: any): Promise<void>;
2
+ export function down(queryInterface: any, Sequelize: any): Promise<void>;
@@ -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
+ };
@@ -102,6 +102,7 @@ UserHasCourseModel.init({
102
102
  type: sequelize_1.DataTypes.STRING,
103
103
  allowNull: true,
104
104
  defaultValue: app_1.USER_COURSE_STATUS.RUNNING,
105
+ field: 'course_status',
105
106
  },
106
107
  walletTransactionId: {
107
108
  type: sequelize_1.DataTypes.STRING,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.529",
3
+ "version": "1.1.530",
4
4
  "description": "Reusable DB core package with Postgres, MongoDB, models, services, interfaces, and types",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",