@kipicore/dbcore 1.1.638 → 1.1.639

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,46 @@
1
+ 'use strict';
2
+ module.exports = {
3
+ up: async (queryInterface, Sequelize) => {
4
+ const table = await queryInterface.describeTable('users');
5
+ if (table.app_type) {
6
+ // In PostgreSQL, changing from ENUM to VARCHAR often requires a USING clause
7
+ try {
8
+ await queryInterface.sequelize.query('ALTER TABLE users ALTER COLUMN app_type TYPE VARCHAR(255) USING app_type::varchar;');
9
+ await queryInterface.changeColumn('users', 'app_type', {
10
+ type: Sequelize.STRING,
11
+ allowNull: true,
12
+ defaultValue: 'INSTITUTE_APP',
13
+ });
14
+ }
15
+ catch (error) {
16
+ // Fallback if the raw query fails
17
+ await queryInterface.changeColumn('users', 'app_type', {
18
+ type: Sequelize.STRING,
19
+ allowNull: true,
20
+ defaultValue: 'INSTITUTE_APP',
21
+ });
22
+ }
23
+ }
24
+ },
25
+ down: async (queryInterface, Sequelize) => {
26
+ const table = await queryInterface.describeTable('users');
27
+ if (table.app_type) {
28
+ try {
29
+ await queryInterface.sequelize.query('ALTER TABLE users ALTER COLUMN app_type TYPE "enum_users_app_type" USING app_type::text::"enum_users_app_type";');
30
+ await queryInterface.changeColumn('users', 'app_type', {
31
+ type: Sequelize.ENUM('INSTITUTE_APP', 'SCHOOL_APP', 'GLOBAL_APP', 'STUDENT_APP'),
32
+ allowNull: true,
33
+ defaultValue: 'INSTITUTE_APP',
34
+ });
35
+ }
36
+ catch (error) {
37
+ // Fallback
38
+ await queryInterface.changeColumn('users', 'app_type', {
39
+ type: Sequelize.ENUM('INSTITUTE_APP', 'SCHOOL_APP', 'GLOBAL_APP', 'STUDENT_APP'),
40
+ allowNull: true,
41
+ defaultValue: 'INSTITUTE_APP',
42
+ });
43
+ }
44
+ }
45
+ }
46
+ };
@@ -156,7 +156,7 @@ UserModel.init({
156
156
  password: { type: sequelize_1.DataTypes.STRING, allowNull: true },
157
157
  emailVerification: { type: sequelize_1.DataTypes.STRING(30), allowNull: false, field: 'email_varification', defaultValue: app_1.EMAIL_VERIFICATION.PENDING },
158
158
  mobileVerification: { type: sequelize_1.DataTypes.STRING(30), allowNull: false, field: 'mobile_varification', defaultValue: app_1.MOBILE_VERIFICATION.PENDING },
159
- appType: { type: sequelize_1.DataTypes.ENUM, values: Object.values(app_1.APP_TYPE), allowNull: true, field: 'app_type', defaultValue: app_1.APP_TYPE.INSTITUTE_APP },
159
+ appType: { type: sequelize_1.DataTypes.STRING, allowNull: true, field: 'app_type', defaultValue: app_1.APP_TYPE.INSTITUTE_APP },
160
160
  type: { type: sequelize_1.DataTypes.STRING(30), allowNull: false },
161
161
  globalId: { type: sequelize_1.DataTypes.STRING, field: 'global_id', defaultValue: null, allowNull: true },
162
162
  address1: { type: sequelize_1.DataTypes.STRING, allowNull: true },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.638",
3
+ "version": "1.1.639",
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",