@kipicore/dbcore 1.1.637 → 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,18 @@
1
+ 'use strict';
2
+ module.exports = {
3
+ up: async (queryInterface, Sequelize) => {
4
+ const tableInfo = await queryInterface.describeTable('class_room_collection');
5
+ if (!tableInfo.batch_id) {
6
+ await queryInterface.addColumn('class_room_collection', 'batch_id', {
7
+ type: Sequelize.UUID,
8
+ allowNull: true,
9
+ });
10
+ }
11
+ },
12
+ down: async (queryInterface, Sequelize) => {
13
+ const tableInfo = await queryInterface.describeTable('class_room_collection');
14
+ if (tableInfo.batch_id) {
15
+ await queryInterface.removeColumn('class_room_collection', 'batch_id');
16
+ }
17
+ }
18
+ };
@@ -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
+ };
@@ -8,6 +8,7 @@ export interface IClassRoomCollectionModelAttributes extends IDefaultAttributes
8
8
  collectorId: string;
9
9
  paymentMethod: PAYMENT_TYPE;
10
10
  userId?: string;
11
+ batchId?: string;
11
12
  amount: number;
12
13
  status: PAYMENT_STATUS;
13
14
  paidDate: Date;
@@ -13,6 +13,7 @@ declare class ClassRoomCollectionModel extends Model<IClassRoomCollectionModelAt
13
13
  classRoomEventId: string;
14
14
  paymentMethod: PAYMENT_TYPE;
15
15
  academicCalendarId?: string;
16
+ batchId?: string;
16
17
  createdBy: string;
17
18
  updatedBy: string;
18
19
  deletedBy: string;
@@ -5,7 +5,7 @@ const index_1 = require("./index");
5
5
  const constants_1 = require("../../constants");
6
6
  class ClassRoomCollectionModel extends sequelize_1.Model {
7
7
  static associate(models) {
8
- const { UserModel, InstituteModel, AcademicCalendarModel, ClassRoomEventModel } = models;
8
+ const { UserModel, InstituteModel, AcademicCalendarModel, ClassRoomEventModel, BatchModel } = models;
9
9
  ClassRoomCollectionModel.belongsTo(UserModel, {
10
10
  foreignKey: {
11
11
  name: 'createdBy',
@@ -106,6 +106,22 @@ class ClassRoomCollectionModel extends sequelize_1.Model {
106
106
  },
107
107
  as: 'classEventClassRCol',
108
108
  });
109
+ ClassRoomCollectionModel.belongsTo(BatchModel, {
110
+ foreignKey: {
111
+ name: 'batchId',
112
+ allowNull: true,
113
+ field: 'batch_id',
114
+ },
115
+ as: 'classRColBatch',
116
+ });
117
+ BatchModel.hasMany(ClassRoomCollectionModel, {
118
+ foreignKey: {
119
+ name: 'batchId',
120
+ allowNull: true,
121
+ field: 'batch_id',
122
+ },
123
+ as: 'batchClassRCol',
124
+ });
109
125
  }
110
126
  }
111
127
  ClassRoomCollectionModel.init({
@@ -154,6 +170,11 @@ ClassRoomCollectionModel.init({
154
170
  field: 'class_room_event_id',
155
171
  allowNull: true,
156
172
  },
173
+ batchId: {
174
+ type: sequelize_1.DataTypes.UUID,
175
+ field: 'batch_id',
176
+ allowNull: true,
177
+ },
157
178
  paidDate: {
158
179
  type: sequelize_1.DataTypes.DATE,
159
180
  field: 'paid_date',
@@ -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.637",
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",