@kipicore/dbcore 1.1.685 → 1.1.686
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/20260728170500-add_sports_academy_id_to_testimonials.d.ts +2 -0
- package/dist/db/psql/migrations/20260728170500-add_sports_academy_id_to_testimonials.js +21 -0
- package/dist/interfaces/photosGalleryInterface.d.ts +3 -1
- package/dist/interfaces/testimonialInterface.d.ts +1 -0
- package/dist/models/mongodb/photosGalleryModel.js +5 -1
- package/dist/models/psql/testimonialModel.d.ts +1 -0
- package/dist/models/psql/testimonialModel.js +8 -7
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const up = async (queryInterface, Sequelize) => {
|
|
3
|
+
const table = await queryInterface.describeTable('testimonials');
|
|
4
|
+
if (!table.sports_academy_id) {
|
|
5
|
+
await queryInterface.addColumn('testimonials', 'sports_academy_id', {
|
|
6
|
+
type: Sequelize.STRING,
|
|
7
|
+
allowNull: true,
|
|
8
|
+
field: 'sports_academy_id',
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const down = async (queryInterface) => {
|
|
13
|
+
const table = await queryInterface.describeTable('testimonials');
|
|
14
|
+
if (table.sports_academy_id) {
|
|
15
|
+
await queryInterface.removeColumn('testimonials', 'sports_academy_id');
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
module.exports = {
|
|
19
|
+
up,
|
|
20
|
+
down,
|
|
21
|
+
};
|
|
@@ -72,12 +72,16 @@ const PhotosGalleryModelSchema = new mongoose_1.Schema({
|
|
|
72
72
|
},
|
|
73
73
|
instituteId: {
|
|
74
74
|
type: String,
|
|
75
|
-
required:
|
|
75
|
+
required: false,
|
|
76
76
|
},
|
|
77
77
|
academicCalendarId: {
|
|
78
78
|
type: String,
|
|
79
79
|
required: false,
|
|
80
80
|
},
|
|
81
|
+
sportsAcademyId: {
|
|
82
|
+
type: String,
|
|
83
|
+
required: false,
|
|
84
|
+
},
|
|
81
85
|
}, { timestamps: true, versionKey: false });
|
|
82
86
|
PhotosGalleryModelSchema.index({
|
|
83
87
|
instituteId: 1,
|
|
@@ -65,7 +65,7 @@ class TestimonialModel extends sequelize_1.Model {
|
|
|
65
65
|
const { InstituteModel, UserModel, InstituteEntityModel } = models;
|
|
66
66
|
const beforeCreateOrUpdateHook = async (testimonial) => {
|
|
67
67
|
let institute = null;
|
|
68
|
-
if (testimonial
|
|
68
|
+
if (testimonial?.instituteId) {
|
|
69
69
|
institute = await InstituteModel.findByPk(testimonial.instituteId);
|
|
70
70
|
if (!institute) {
|
|
71
71
|
throw new Error(errorMessages_1.INSTITUTE_ERROR_MESSAGES.NOT_FOUND);
|
|
@@ -80,7 +80,7 @@ class TestimonialModel extends sequelize_1.Model {
|
|
|
80
80
|
testimonial.userType = user.type;
|
|
81
81
|
}
|
|
82
82
|
testimonial.class = `${(0, utils_1.fromSnakeCaseToNormalText)(testimonial.userType)}`;
|
|
83
|
-
if (testimonial.userId && testimonial
|
|
83
|
+
if (testimonial.userId && testimonial?.instituteId && testimonial.userType !== app_1.USER_TYPES.PARENTS) {
|
|
84
84
|
const userInstituteMetaWhere = {
|
|
85
85
|
userId: testimonial.userId,
|
|
86
86
|
instituteId: testimonial.instituteId,
|
|
@@ -105,11 +105,7 @@ class TestimonialModel extends sequelize_1.Model {
|
|
|
105
105
|
association: 'entityType',
|
|
106
106
|
required: true,
|
|
107
107
|
where: {
|
|
108
|
-
[sequelize_1.Op.or]: [
|
|
109
|
-
{ title: { [sequelize_1.Op.iLike]: 'STANDARD' } },
|
|
110
|
-
{ title: { [sequelize_1.Op.iLike]: 'MEDIUM' } },
|
|
111
|
-
{ title: { [sequelize_1.Op.iLike]: 'SECTIONS' } },
|
|
112
|
-
],
|
|
108
|
+
[sequelize_1.Op.or]: [{ title: { [sequelize_1.Op.iLike]: 'STANDARD' } }, { title: { [sequelize_1.Op.iLike]: 'MEDIUM' } }, { title: { [sequelize_1.Op.iLike]: 'SECTIONS' } }],
|
|
113
109
|
},
|
|
114
110
|
},
|
|
115
111
|
});
|
|
@@ -172,6 +168,11 @@ TestimonialModel.init({
|
|
|
172
168
|
field: 'academic_calendar_id',
|
|
173
169
|
allowNull: true,
|
|
174
170
|
},
|
|
171
|
+
sportsAcademyId: {
|
|
172
|
+
type: sequelize_1.DataTypes.STRING,
|
|
173
|
+
field: 'sports_academy_id',
|
|
174
|
+
allowNull: true,
|
|
175
|
+
},
|
|
175
176
|
}, {
|
|
176
177
|
modelName: 'TestimonialModel',
|
|
177
178
|
tableName: 'testimonials',
|
package/package.json
CHANGED