@kipicore/dbcore 1.1.136 → 1.1.137

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
+ // Remove old index if exists
4
+ const oldIndexes = await queryInterface.showIndex('floor_management');
5
+ const hasOldIndex = oldIndexes.some(idx => idx.name === 'institute_floor_id');
6
+ if (hasOldIndex) {
7
+ await queryInterface.removeIndex('floor_management', 'institute_floor_id');
8
+ }
9
+ // Add new index if not exists
10
+ const newIndexName = 'institute_floor_academic_calendar_unique';
11
+ const newIndexes = await queryInterface.showIndex('floor_management');
12
+ const hasNewIndex = newIndexes.some(idx => idx.name === newIndexName);
13
+ if (!hasNewIndex) {
14
+ await queryInterface.addIndex('floor_management', ['institute_id', 'floor_number', 'academic_calendar_id'], {
15
+ name: newIndexName,
16
+ unique: true,
17
+ where: { deleted_at: null },
18
+ });
19
+ }
20
+ };
21
+ const down = async (queryInterface, Sequelize) => {
22
+ const newIndexName = 'institute_floor_academic_calendar_unique';
23
+ const indexes = await queryInterface.showIndex('floor_management');
24
+ const hasNewIndex = indexes.some(idx => idx.name === newIndexName);
25
+ if (hasNewIndex) {
26
+ await queryInterface.removeIndex('floor_management', newIndexName);
27
+ }
28
+ const hasOldIndex = indexes.some(idx => idx.name === 'institute_floor_id');
29
+ if (!hasOldIndex) {
30
+ await queryInterface.addIndex('floor_management', ['institute_id', 'floor_number'], {
31
+ name: 'institute_floor_id',
32
+ unique: true,
33
+ where: { deleted_at: null },
34
+ });
35
+ }
36
+ };
37
+ module.exports = {
38
+ up,
39
+ down,
40
+ };
@@ -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
+ // Remove old index if exists
4
+ const oldIndexes = await queryInterface.showIndex('slots');
5
+ const hasOldIndex = oldIndexes.some(idx => idx.name === 'institute_id_name');
6
+ if (hasOldIndex) {
7
+ await queryInterface.removeIndex('slots', 'institute_id_name');
8
+ }
9
+ // Add new index if not exists
10
+ const newIndexName = 'institute_id_name';
11
+ const newIndexes = await queryInterface.showIndex('slots');
12
+ const hasNewIndex = newIndexes.some(idx => idx.name === newIndexName);
13
+ if (!hasNewIndex) {
14
+ await queryInterface.addIndex('slots', ['institute_id', 'name', 'type', 'academic_calendar_id'], {
15
+ name: newIndexName,
16
+ unique: true,
17
+ where: { deleted_at: null },
18
+ });
19
+ }
20
+ };
21
+ const down = async (queryInterface, Sequelize) => {
22
+ const newIndexName = 'institute_id_name';
23
+ const indexes = await queryInterface.showIndex('slots');
24
+ const hasNewIndex = indexes.some(idx => idx.name === newIndexName);
25
+ if (hasNewIndex) {
26
+ await queryInterface.removeIndex('slots', newIndexName);
27
+ }
28
+ const hasOldIndex = indexes.some(idx => idx.name === 'institute_id_name');
29
+ if (!hasOldIndex) {
30
+ await queryInterface.addIndex('slots', ['institute_id', 'name', 'type'], {
31
+ name: 'institute_id_name',
32
+ unique: true,
33
+ where: { deleted_at: null },
34
+ });
35
+ }
36
+ };
37
+ module.exports = {
38
+ up,
39
+ down,
40
+ };
@@ -79,15 +79,15 @@ FloorManagementModel.init({
79
79
  type: sequelize_1.DataTypes.UUID,
80
80
  field: 'old_id',
81
81
  allowNull: true,
82
- }
82
+ },
83
83
  }, {
84
84
  modelName: 'FloorManagementModel',
85
85
  tableName: 'floor_management',
86
86
  indexes: [
87
87
  {
88
- name: 'institute_floor_id',
88
+ name: 'institute_floor_academic_calendar_unique',
89
89
  unique: true,
90
- fields: ['institute_id', 'floor_number'],
90
+ fields: ['institute_id', 'floor_number', 'academic_calendar_id'],
91
91
  where: { deleted_at: null },
92
92
  },
93
93
  ],
@@ -103,7 +103,7 @@ SlotModel.init({
103
103
  {
104
104
  name: 'institute_id_name',
105
105
  unique: true,
106
- fields: ['institute_id', 'name', 'type'],
106
+ fields: ['institute_id', 'name', 'type', 'academic_calendar_id'],
107
107
  where: { deleted_at: null },
108
108
  },
109
109
  ],
@@ -94,7 +94,7 @@ class MongooseCommonService {
94
94
  createData.map((data) => {
95
95
  data.createdBy = options.userId;
96
96
  return data;
97
- }), options);
97
+ }), { ...options, ordered: true });
98
98
  }
99
99
  async delete(filter, options = {}) {
100
100
  return this.model.updateMany(filter, { deletedBy: options.userId, deletedAt: new Date() }, options).exec();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kipicore/dbcore",
3
- "version": "1.1.136",
3
+ "version": "1.1.137",
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",