@kipicore/dbcore 1.1.166 → 1.1.167
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/20251222042805-add_acl_in_driver.d.ts +2 -0
- package/dist/db/psql/migrations/20251222042805-add_acl_in_driver.js +22 -0
- package/dist/interfaces/driverInterface.d.ts +1 -0
- package/dist/models/psql/driverModel.d.ts +1 -0
- package/dist/models/psql/driverModel.js +14 -1
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const up = async (queryInterface, Sequelize) => {
|
|
3
|
+
const table = await queryInterface.describeTable('drivers');
|
|
4
|
+
if (!table.academic_calendar_id) {
|
|
5
|
+
await queryInterface.addColumn('drivers', 'academic_calendar_id', {
|
|
6
|
+
type: Sequelize.UUID,
|
|
7
|
+
defaultValue: null,
|
|
8
|
+
allowNull: true,
|
|
9
|
+
field: 'academic_calendar_id',
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const down = async (queryInterface, Sequelize) => {
|
|
14
|
+
const table = await queryInterface.describeTable('drivers');
|
|
15
|
+
if (table.academic_calendar_id) {
|
|
16
|
+
await queryInterface.removeColumn('drivers', 'academic_calendar_id');
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
module.exports = {
|
|
20
|
+
up,
|
|
21
|
+
down,
|
|
22
|
+
};
|
|
@@ -11,7 +11,7 @@ const instituteModel_1 = __importDefault(require("./instituteModel"));
|
|
|
11
11
|
const errorMessages_1 = require("../../constants/errorMessages");
|
|
12
12
|
class DriverModel extends sequelize_1.Model {
|
|
13
13
|
static associate(models) {
|
|
14
|
-
const { UserModel, InstituteModel, CountryModel, StateModel, CityModel, FileStorageModel, CampusModel } = models;
|
|
14
|
+
const { UserModel, InstituteModel, CountryModel, StateModel, CityModel, FileStorageModel, CampusModel, AcademicCalendarModel } = models;
|
|
15
15
|
DriverModel.belongsTo(UserModel, {
|
|
16
16
|
foreignKey: { name: 'createdBy', allowNull: true, field: 'created_by' },
|
|
17
17
|
as: 'createdByUser',
|
|
@@ -64,6 +64,14 @@ class DriverModel extends sequelize_1.Model {
|
|
|
64
64
|
foreignKey: 'campusId',
|
|
65
65
|
as: 'campusHasDrivers',
|
|
66
66
|
});
|
|
67
|
+
DriverModel.belongsTo(AcademicCalendarModel, {
|
|
68
|
+
foreignKey: 'academicCalendarId',
|
|
69
|
+
as: 'driverAcademic',
|
|
70
|
+
});
|
|
71
|
+
AcademicCalendarModel.hasMany(DriverModel, {
|
|
72
|
+
foreignKey: 'academicCalendarId',
|
|
73
|
+
as: 'academicHasDrivers',
|
|
74
|
+
});
|
|
67
75
|
}
|
|
68
76
|
static addHooks() {
|
|
69
77
|
const beforeCreateOrUpdateHook = async (driver) => {
|
|
@@ -105,6 +113,11 @@ DriverModel.init({
|
|
|
105
113
|
field: 'institute_id',
|
|
106
114
|
allowNull: true,
|
|
107
115
|
},
|
|
116
|
+
academicCalendarId: {
|
|
117
|
+
type: sequelize_1.DataTypes.UUID,
|
|
118
|
+
field: 'academic_calendar_id',
|
|
119
|
+
allowNull: true,
|
|
120
|
+
},
|
|
108
121
|
address1: {
|
|
109
122
|
type: sequelize_1.DataTypes.STRING,
|
|
110
123
|
allowNull: true,
|
package/package.json
CHANGED