@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.
- package/dist/db/psql/migrations/20251211095127-remove_index_add_in_floor.d.ts +2 -0
- package/dist/db/psql/migrations/20251211095127-remove_index_add_in_floor.js +40 -0
- package/dist/db/psql/migrations/20251211100316-remove_index_add_in_slot.d.ts +2 -0
- package/dist/db/psql/migrations/20251211100316-remove_index_add_in_slot.js +40 -0
- package/dist/models/psql/floorManagementModel.js +3 -3
- package/dist/models/psql/slotModel.js +1 -1
- package/dist/services/Concrete/mongooseCommonService.js +1 -1
- package/package.json +1 -1
|
@@ -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,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: '
|
|
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
|
],
|
|
@@ -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