@kipicore/dbcore 1.1.669 → 1.1.670
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/configs/env.d.ts +0 -2
- package/dist/configs/env.js +0 -4
- package/dist/configs/index.d.ts +0 -2
- package/dist/configs/index.js +0 -2
- package/dist/constants/app.d.ts +13 -20
- package/dist/constants/app.js +23 -31
- package/dist/constants/errorMessages.d.ts +0 -17
- package/dist/constants/errorMessages.js +1 -20
- package/dist/constants/successMessages.d.ts +0 -14
- package/dist/constants/successMessages.js +1 -17
- package/dist/db/psql/migrations/20260714095754-create-arena-models.js +642 -0
- package/dist/db/psql/migrations/20260720092201-replace-facility-sports-with-sport-group-data.d.ts +2 -0
- package/dist/db/psql/migrations/20260720092201-replace-facility-sports-with-sport-group-data.js +138 -0
- package/dist/helpers/index.d.ts +0 -3
- package/dist/helpers/index.js +0 -3
- package/dist/helpers/utils.d.ts +3 -5
- package/dist/helpers/utils.js +31 -58
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -4
- package/dist/interfaces/ageGroupInterface.d.ts +12 -0
- package/dist/interfaces/assessmentTestInterface.d.ts +24 -0
- package/dist/interfaces/categoriesInterface.d.ts +1 -2
- package/dist/interfaces/equipmentInterface.d.ts +10 -0
- package/dist/interfaces/equipmentInterface.js +2 -0
- package/dist/interfaces/facilityMasterInterface.d.ts +9 -0
- package/dist/interfaces/facilityMasterInterface.js +2 -0
- package/dist/interfaces/index.d.ts +12 -1
- package/dist/interfaces/index.js +13 -1
- package/dist/interfaces/instituteInterface.d.ts +0 -1
- package/dist/interfaces/skillInterface.d.ts +15 -0
- package/dist/interfaces/skillInterface.js +2 -0
- package/dist/interfaces/sportCategoryInterface.d.ts +9 -0
- package/dist/interfaces/sportCategoryInterface.js +2 -0
- package/dist/interfaces/sportGroupDataInterface.d.ts +7 -0
- package/dist/interfaces/sportGroupDataInterface.js +2 -0
- package/dist/interfaces/sportInfoInterface.d.ts +23 -0
- package/dist/interfaces/sportInfoInterface.js +2 -0
- package/dist/interfaces/sportInterface.d.ts +10 -0
- package/dist/interfaces/sportInterface.js +2 -0
- package/dist/interfaces/sportRoleInterface.d.ts +11 -0
- package/dist/interfaces/sportRoleInterface.js +2 -0
- package/dist/interfaces/sportSubCategoryInterface.d.ts +10 -0
- package/dist/interfaces/sportSubCategoryInterface.js +2 -0
- package/dist/interfaces/subCategoriesInterface.d.ts +1 -2
- package/dist/interfaces/subscriptionPlanInterface.d.ts +1 -2
- package/dist/interfaces/unitInterface.d.ts +10 -0
- package/dist/interfaces/unitInterface.js +2 -0
- package/dist/interfaces/userInterface.d.ts +1 -2
- package/dist/interfaces/vendorCompanyMetaInterface.d.ts +1 -2
- package/dist/models/mongodb/assessmentTestModel.d.ts +4 -0
- package/dist/models/mongodb/assessmentTestModel.js +72 -0
- package/dist/models/mongodb/index.d.ts +2 -0
- package/dist/models/mongodb/index.js +6 -1
- package/dist/models/mongodb/productMetaModel.js +0 -8
- package/dist/models/mongodb/sportInfoModel.d.ts +4 -0
- package/dist/models/mongodb/sportInfoModel.js +71 -0
- package/dist/models/mongodb/subscriptionPlanModel.js +0 -5
- package/dist/models/mongodb/vendorCompanyMetaModel.js +1 -6
- package/dist/models/psql/SubCategoriesModel.d.ts +1 -2
- package/dist/models/psql/SubCategoriesModel.js +0 -5
- package/dist/models/psql/ageGroupModel.d.ts +22 -0
- package/dist/models/psql/ageGroupModel.js +76 -0
- package/dist/models/psql/categoriesModel.d.ts +1 -2
- package/dist/models/psql/categoriesModel.js +0 -5
- package/dist/models/psql/equipmentModel.d.ts +20 -0
- package/dist/models/psql/equipmentModel.js +57 -0
- package/dist/models/psql/facilityMasterModel.d.ts +18 -0
- package/dist/models/psql/facilityMasterModel.js +64 -0
- package/dist/models/psql/fileStorageModel.js +4 -3
- package/dist/models/psql/index.d.ts +10 -1
- package/dist/models/psql/index.js +23 -4
- package/dist/models/psql/instituteModel.d.ts +0 -1
- package/dist/models/psql/instituteModel.js +2 -5
- package/dist/models/psql/skillModel.d.ts +25 -0
- package/dist/models/psql/skillModel.js +99 -0
- package/dist/models/psql/sportCategoryModel.d.ts +19 -0
- package/dist/models/psql/sportCategoryModel.js +53 -0
- package/dist/models/psql/sportGroupDataModel.d.ts +13 -0
- package/dist/models/psql/sportGroupDataModel.js +64 -0
- package/dist/models/psql/sportModel.d.ts +20 -0
- package/dist/models/psql/sportModel.js +58 -0
- package/dist/models/psql/sportRoleModel.d.ts +21 -0
- package/dist/models/psql/sportRoleModel.js +71 -0
- package/dist/models/psql/sportSubCategoryModel.d.ts +20 -0
- package/dist/models/psql/sportSubCategoryModel.js +75 -0
- package/dist/models/psql/unitModel.d.ts +20 -0
- package/dist/models/psql/unitModel.js +57 -0
- package/dist/models/psql/userModel.d.ts +1 -2
- package/dist/models/psql/userModel.js +0 -1
- package/dist/types/ageGroupType.d.ts +2 -0
- package/dist/types/ageGroupType.js +2 -0
- package/dist/types/assessmentTestType.d.ts +2 -0
- package/dist/types/assessmentTestType.js +2 -0
- package/dist/types/commonType.d.ts +1 -29
- package/dist/types/equipmentType.d.ts +2 -0
- package/dist/types/equipmentType.js +2 -0
- package/dist/types/facilityMasterType.d.ts +3 -0
- package/dist/types/facilityMasterType.js +2 -0
- package/dist/types/index.d.ts +12 -1
- package/dist/types/index.js +13 -1
- package/dist/types/skillType.d.ts +2 -0
- package/dist/types/skillType.js +2 -0
- package/dist/types/sportCategoryType.d.ts +2 -0
- package/dist/types/sportCategoryType.js +2 -0
- package/dist/types/sportGroupDataType.d.ts +3 -0
- package/dist/types/sportGroupDataType.js +2 -0
- package/dist/types/sportInfoType.d.ts +2 -0
- package/dist/types/sportInfoType.js +2 -0
- package/dist/types/sportRoleType.d.ts +2 -0
- package/dist/types/sportRoleType.js +2 -0
- package/dist/types/sportSubCategoryType.d.ts +2 -0
- package/dist/types/sportSubCategoryType.js +2 -0
- package/dist/types/sportType.d.ts +2 -0
- package/dist/types/sportType.js +2 -0
- package/dist/types/unitType.d.ts +2 -0
- package/dist/types/unitType.js +2 -0
- package/package.json +3 -11
- package/dist/commonValidator/commandValidator.d.ts +0 -27
- package/dist/commonValidator/commandValidator.js +0 -225
- package/dist/commonValidator/index.d.ts +0 -3
- package/dist/commonValidator/index.js +0 -24
- package/dist/commonValidator/joiCommonValidator.d.ts +0 -12
- package/dist/commonValidator/joiCommonValidator.js +0 -47
- package/dist/commonValidator/joiSchemaBuilder.d.ts +0 -6
- package/dist/commonValidator/joiSchemaBuilder.js +0 -70
- package/dist/configs/logger.d.ts +0 -2
- package/dist/configs/logger.js +0 -44
- package/dist/configs/redisConfig.d.ts +0 -4
- package/dist/configs/redisConfig.js +0 -32
- package/dist/db/psql/migrations/20260714111425-change_status_enum_to_string_in_institutes.js +0 -46
- package/dist/db/psql/migrations/20260714131500-add_note_to_institutes.d.ts +0 -2
- package/dist/db/psql/migrations/20260714131500-add_note_to_institutes.js +0 -20
- package/dist/db/psql/migrations/20260715150000-create-ai-model-keys.d.ts +0 -2
- package/dist/db/psql/migrations/20260715150000-create-ai-model-keys.js +0 -156
- package/dist/db/psql/migrations/20260717071354-add_type_to_categories.d.ts +0 -2
- package/dist/db/psql/migrations/20260717071354-add_type_to_categories.js +0 -19
- package/dist/db/psql/migrations/20260717072745-add_type_to_sub_categories.d.ts +0 -2
- package/dist/db/psql/migrations/20260717072745-add_type_to_sub_categories.js +0 -19
- package/dist/db/psql/migrations/20260717095051-add_status_to_users.d.ts +0 -2
- package/dist/db/psql/migrations/20260717095051-add_status_to_users.js +0 -19
- package/dist/db/psql/migrations/20260721000001-add-deleted-at-to-rms-maintenance-activities.d.ts +0 -2
- package/dist/db/psql/migrations/20260721000001-add-deleted-at-to-rms-maintenance-activities.js +0 -12
- package/dist/db/psql/migrations/20260721000002-change-uploaded-from-enum-to-string-in-file-storage.d.ts +0 -2
- package/dist/db/psql/migrations/20260721000002-change-uploaded-from-enum-to-string-in-file-storage.js +0 -42
- package/dist/helpers/sendEmail.d.ts +0 -3
- package/dist/helpers/sendEmail.js +0 -117
- package/dist/helpers/sendNotification.d.ts +0 -4
- package/dist/helpers/sendNotification.js +0 -34
- package/dist/helpers/sendSMS.d.ts +0 -5
- package/dist/helpers/sendSMS.js +0 -34
- package/dist/interfaces/aiModelKeysInterface.d.ts +0 -15
- package/dist/models/psql/aiModelKeysModel.d.ts +0 -20
- package/dist/models/psql/aiModelKeysModel.js +0 -70
- package/dist/queues/emailQueue.d.ts +0 -3
- package/dist/queues/emailQueue.js +0 -22
- package/dist/queues/emailWorker.d.ts +0 -3
- package/dist/queues/emailWorker.js +0 -33
- package/dist/queues/index.d.ts +0 -2
- package/dist/queues/index.js +0 -18
- package/dist/types/aiModelKeysType.d.ts +0 -3
- /package/dist/db/psql/migrations/{20260714111425-change_status_enum_to_string_in_institutes.d.ts → 20260714095754-create-arena-models.d.ts} +0 -0
- /package/dist/interfaces/{aiModelKeysInterface.js → ageGroupInterface.js} +0 -0
- /package/dist/{types/aiModelKeysType.js → interfaces/assessmentTestInterface.js} +0 -0
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.uuidIdAlternatives = exports.objectIdAlternatives = exports.enumAlternatives = exports.paginationValidators = void 0;
|
|
7
|
-
const joi_1 = __importDefault(require("joi"));
|
|
8
|
-
exports.paginationValidators = {
|
|
9
|
-
page: joi_1.default.number().integer().min(1).default(1),
|
|
10
|
-
limit: joi_1.default.number().integer().min(1).default(10),
|
|
11
|
-
search: joi_1.default.string().trim(),
|
|
12
|
-
isPaginate: joi_1.default.boolean().default(true),
|
|
13
|
-
order: joi_1.default.array().items(joi_1.default.array().items(joi_1.default.string().trim(), joi_1.default.string().trim())),
|
|
14
|
-
sort: joi_1.default.string()
|
|
15
|
-
.pattern(/^(-?\\w+(,-?\\w+)*)?$/)
|
|
16
|
-
.optional()
|
|
17
|
-
.messages({
|
|
18
|
-
'string.pattern.base': `"sort" must be a comma-separated list of field names, optionally prefixed with '-' for descending`,
|
|
19
|
-
}),
|
|
20
|
-
};
|
|
21
|
-
const enumAlternatives = (enumObj, isRequired = false, allowArray = true) => {
|
|
22
|
-
const base = joi_1.default.string().valid(...Object.values(enumObj));
|
|
23
|
-
if (allowArray) {
|
|
24
|
-
const alt = joi_1.default.alternatives().try(base, joi_1.default.array().items(base));
|
|
25
|
-
return isRequired ? alt.required() : alt.optional();
|
|
26
|
-
}
|
|
27
|
-
return isRequired ? base.required() : base.optional();
|
|
28
|
-
};
|
|
29
|
-
exports.enumAlternatives = enumAlternatives;
|
|
30
|
-
const objectIdAlternatives = (isRequired = false, allowArray = true) => {
|
|
31
|
-
const base = joi_1.default.string()
|
|
32
|
-
.pattern(/^[0-9a-fA-F]{24}$/)
|
|
33
|
-
.message('Invalid ObjectId format');
|
|
34
|
-
if (allowArray) {
|
|
35
|
-
const alt = joi_1.default.alternatives().try(base, joi_1.default.array().items(base));
|
|
36
|
-
return isRequired ? alt.required() : alt.optional();
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
exports.objectIdAlternatives = objectIdAlternatives;
|
|
40
|
-
const uuidIdAlternatives = (isRequired = false, allowArray = true) => {
|
|
41
|
-
const base = joi_1.default.string().uuid().message('Invalid Uuid format');
|
|
42
|
-
if (allowArray) {
|
|
43
|
-
const alt = joi_1.default.alternatives().try(base, joi_1.default.array().items(base));
|
|
44
|
-
return isRequired ? alt.required() : alt.optional();
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
exports.uuidIdAlternatives = uuidIdAlternatives;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import Joi from 'joi';
|
|
2
|
-
import { SchemaRules } from '../types/commonType';
|
|
3
|
-
export declare const buildSchema: <TModel extends Record<string, any>, Keys extends keyof TModel & string = keyof TModel & string>(base: Joi.ObjectSchema<TModel>, rules?: SchemaRules<Keys>) => Joi.ObjectSchema<TModel>;
|
|
4
|
-
export default class BaseValidator {
|
|
5
|
-
protected validate(schema: Joi.ObjectSchema, req: any, options?: Joi.ValidationOptions): void;
|
|
6
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.buildSchema = void 0;
|
|
7
|
-
const joi_1 = __importDefault(require("joi"));
|
|
8
|
-
const httpStatusCode_1 = require("../constants/httpStatusCode");
|
|
9
|
-
class ApiError extends Error {
|
|
10
|
-
constructor(statusCode, message, isOperational = true, stack = '') {
|
|
11
|
-
super(message);
|
|
12
|
-
this.statusCode = statusCode;
|
|
13
|
-
this.isOperational = isOperational;
|
|
14
|
-
if (stack) {
|
|
15
|
-
this.stack = stack;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
Error.captureStackTrace(this, this.constructor);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
// GENERIC BUILDER
|
|
23
|
-
const buildSchema = (base, rules = {}) => {
|
|
24
|
-
let schema = base;
|
|
25
|
-
// REQUIRED
|
|
26
|
-
if (rules.required) {
|
|
27
|
-
schema = schema.fork(rules.required, field => field.required());
|
|
28
|
-
}
|
|
29
|
-
// OPTIONAL
|
|
30
|
-
if (rules.optional) {
|
|
31
|
-
schema = schema.fork(rules.optional, field => field.optional());
|
|
32
|
-
}
|
|
33
|
-
// ALLOW NULL
|
|
34
|
-
if (rules.allowNull) {
|
|
35
|
-
schema = schema.fork(rules.allowNull, field => field.allow(null));
|
|
36
|
-
}
|
|
37
|
-
// FORBIDDEN
|
|
38
|
-
if (rules.forbidden) {
|
|
39
|
-
schema = schema.fork(rules.forbidden, field => field.forbidden());
|
|
40
|
-
}
|
|
41
|
-
// SINGLE OR ARRAY
|
|
42
|
-
if (rules.singleOrArray) {
|
|
43
|
-
schema = schema.fork(rules.singleOrArray, field => joi_1.default.alternatives().try(field, joi_1.default.array().items(field)));
|
|
44
|
-
}
|
|
45
|
-
// SINGLE OR ARRAY OR NULL
|
|
46
|
-
if (rules.singleOrArrayOrNull) {
|
|
47
|
-
schema = schema.fork(rules.singleOrArrayOrNull, field => joi_1.default.alternatives().try(field, joi_1.default.array().items(field), joi_1.default.valid(null)));
|
|
48
|
-
}
|
|
49
|
-
// CUSTOM FIELDS
|
|
50
|
-
if (rules.customFields) {
|
|
51
|
-
schema = schema.append(rules.customFields);
|
|
52
|
-
}
|
|
53
|
-
return schema;
|
|
54
|
-
};
|
|
55
|
-
exports.buildSchema = buildSchema;
|
|
56
|
-
const defaultOptions = {
|
|
57
|
-
abortEarly: false,
|
|
58
|
-
allowUnknown: false,
|
|
59
|
-
};
|
|
60
|
-
class BaseValidator {
|
|
61
|
-
validate(schema, req, options) {
|
|
62
|
-
const { error, value } = schema.validate({ ...req.body, ...req.query, ...req.params }, { ...defaultOptions, ...options });
|
|
63
|
-
if (error) {
|
|
64
|
-
const errorMessage = error.details.map(d => d.message).join(', ');
|
|
65
|
-
throw new ApiError(httpStatusCode_1.HTTP_STATUS_CODE.BAD_REQUEST, errorMessage);
|
|
66
|
-
}
|
|
67
|
-
req.body = value;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.default = BaseValidator;
|
package/dist/configs/logger.d.ts
DELETED
package/dist/configs/logger.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.logger = void 0;
|
|
7
|
-
const winston_1 = __importDefault(require("winston"));
|
|
8
|
-
const winston_daily_rotate_file_1 = __importDefault(require("winston-daily-rotate-file"));
|
|
9
|
-
const env_1 = require("../configs/env");
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
-
const enumerateErrorFormat = winston_1.default.format((info) => {
|
|
12
|
-
if (info.message instanceof Error) {
|
|
13
|
-
info.message = {
|
|
14
|
-
message: info.message.message,
|
|
15
|
-
stack: info.message.stack,
|
|
16
|
-
...info.message,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
if (info instanceof Error) {
|
|
20
|
-
return {
|
|
21
|
-
// message: info.message,
|
|
22
|
-
stack: info.stack,
|
|
23
|
-
...info,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
return info;
|
|
27
|
-
});
|
|
28
|
-
const transport = new winston_daily_rotate_file_1.default({
|
|
29
|
-
filename: env_1.ENV_VARIABLE.LOG_FOLDER + env_1.ENV_VARIABLE.LOG_FILE,
|
|
30
|
-
datePattern: 'YYYY-MM-DD',
|
|
31
|
-
zippedArchive: true,
|
|
32
|
-
maxSize: '20m',
|
|
33
|
-
maxFiles: '3',
|
|
34
|
-
// prepend: true,
|
|
35
|
-
});
|
|
36
|
-
exports.logger = winston_1.default.createLogger({
|
|
37
|
-
format: winston_1.default.format.combine(enumerateErrorFormat(), winston_1.default.format.json()),
|
|
38
|
-
transports: [
|
|
39
|
-
transport,
|
|
40
|
-
new winston_1.default.transports.Console({
|
|
41
|
-
level: 'info',
|
|
42
|
-
}),
|
|
43
|
-
],
|
|
44
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.connectRedis = void 0;
|
|
7
|
-
const ioredis_1 = __importDefault(require("ioredis"));
|
|
8
|
-
const logger_1 = require("./logger");
|
|
9
|
-
const env_1 = require("./env");
|
|
10
|
-
// const redisClient = new Redis(ENV_VARIABLE.REDIS_URL, {
|
|
11
|
-
// maxRetriesPerRequest: null,
|
|
12
|
-
// });
|
|
13
|
-
const redisClient = new ioredis_1.default({
|
|
14
|
-
host: env_1.ENV_VARIABLE.REDIS_HOST || 'redis',
|
|
15
|
-
port: 6379,
|
|
16
|
-
maxRetriesPerRequest: null,
|
|
17
|
-
});
|
|
18
|
-
redisClient.on('error', err => {
|
|
19
|
-
console.error('Redis Client Error', err);
|
|
20
|
-
logger_1.logger.error(err);
|
|
21
|
-
});
|
|
22
|
-
const connectRedis = async () => {
|
|
23
|
-
// ioredis connects automatically, but we can check the status
|
|
24
|
-
if (redisClient.status === 'ready')
|
|
25
|
-
return;
|
|
26
|
-
return new Promise((resolve, reject) => {
|
|
27
|
-
redisClient.once('ready', () => resolve());
|
|
28
|
-
redisClient.once('error', err => reject(err));
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
exports.connectRedis = connectRedis;
|
|
32
|
-
exports.default = redisClient;
|
package/dist/db/psql/migrations/20260714111425-change_status_enum_to_string_in_institutes.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
module.exports = {
|
|
3
|
-
up: async (queryInterface, Sequelize) => {
|
|
4
|
-
const table = await queryInterface.describeTable('institutes');
|
|
5
|
-
if (table.status) {
|
|
6
|
-
// In PostgreSQL, changing from ENUM to VARCHAR often requires a USING clause
|
|
7
|
-
try {
|
|
8
|
-
await queryInterface.sequelize.query('ALTER TABLE institutes ALTER COLUMN status TYPE VARCHAR(255) USING status::varchar;');
|
|
9
|
-
await queryInterface.changeColumn('institutes', 'status', {
|
|
10
|
-
type: Sequelize.STRING,
|
|
11
|
-
allowNull: false,
|
|
12
|
-
defaultValue: 'ACTIVE',
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
// Fallback if the raw query fails
|
|
17
|
-
await queryInterface.changeColumn('institutes', 'status', {
|
|
18
|
-
type: Sequelize.STRING,
|
|
19
|
-
allowNull: false,
|
|
20
|
-
defaultValue: 'ACTIVE',
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
down: async (queryInterface, Sequelize) => {
|
|
26
|
-
const table = await queryInterface.describeTable('institutes');
|
|
27
|
-
if (table.status) {
|
|
28
|
-
try {
|
|
29
|
-
await queryInterface.sequelize.query('ALTER TABLE institutes ALTER COLUMN status TYPE "enum_institutes_status" USING status::text::"enum_institutes_status";');
|
|
30
|
-
await queryInterface.changeColumn('institutes', 'status', {
|
|
31
|
-
type: Sequelize.ENUM('ACTIVE', 'INACTIVE', 'PENDING', 'BLOCKED'), // Typical statuses, can adapt if needed
|
|
32
|
-
allowNull: false,
|
|
33
|
-
defaultValue: 'ACTIVE',
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
// Fallback
|
|
38
|
-
await queryInterface.changeColumn('institutes', 'status', {
|
|
39
|
-
type: Sequelize.ENUM('ACTIVE', 'INACTIVE', 'PENDING', 'BLOCKED'),
|
|
40
|
-
allowNull: false,
|
|
41
|
-
defaultValue: 'ACTIVE',
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const up = async (queryInterface, Sequelize) => {
|
|
3
|
-
const table = await queryInterface.describeTable('institutes');
|
|
4
|
-
if (!table.note) {
|
|
5
|
-
await queryInterface.addColumn('institutes', 'note', {
|
|
6
|
-
type: Sequelize.STRING,
|
|
7
|
-
allowNull: true,
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
const down = async (queryInterface) => {
|
|
12
|
-
const table = await queryInterface.describeTable('institutes');
|
|
13
|
-
if (table.note) {
|
|
14
|
-
await queryInterface.removeColumn('institutes', 'note');
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
module.exports = {
|
|
18
|
-
up,
|
|
19
|
-
down,
|
|
20
|
-
};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const up = async (queryInterface, Sequelize) => {
|
|
3
|
-
const tableName = 'ai_model_keys';
|
|
4
|
-
const tableExists = await queryInterface
|
|
5
|
-
.describeTable(tableName)
|
|
6
|
-
.then(() => true)
|
|
7
|
-
.catch(() => false);
|
|
8
|
-
if (!tableExists) {
|
|
9
|
-
await queryInterface.createTable(tableName, {
|
|
10
|
-
id: {
|
|
11
|
-
type: Sequelize.UUID,
|
|
12
|
-
defaultValue: Sequelize.UUIDV4,
|
|
13
|
-
allowNull: false,
|
|
14
|
-
primaryKey: true,
|
|
15
|
-
},
|
|
16
|
-
key: {
|
|
17
|
-
type: Sequelize.STRING,
|
|
18
|
-
allowNull: false,
|
|
19
|
-
unique: true,
|
|
20
|
-
},
|
|
21
|
-
hasValue: {
|
|
22
|
-
type: Sequelize.STRING,
|
|
23
|
-
allowNull: false,
|
|
24
|
-
field: 'has_value',
|
|
25
|
-
},
|
|
26
|
-
type: {
|
|
27
|
-
type: Sequelize.STRING,
|
|
28
|
-
allowNull: false,
|
|
29
|
-
},
|
|
30
|
-
description: {
|
|
31
|
-
type: Sequelize.TEXT,
|
|
32
|
-
allowNull: false,
|
|
33
|
-
},
|
|
34
|
-
version: {
|
|
35
|
-
type: Sequelize.INTEGER,
|
|
36
|
-
allowNull: false,
|
|
37
|
-
defaultValue: 1,
|
|
38
|
-
},
|
|
39
|
-
createdBy: {
|
|
40
|
-
type: Sequelize.UUID,
|
|
41
|
-
allowNull: true,
|
|
42
|
-
field: 'created_by',
|
|
43
|
-
},
|
|
44
|
-
updatedBy: {
|
|
45
|
-
type: Sequelize.UUID,
|
|
46
|
-
allowNull: true,
|
|
47
|
-
field: 'updated_by',
|
|
48
|
-
},
|
|
49
|
-
deletedBy: {
|
|
50
|
-
type: Sequelize.UUID,
|
|
51
|
-
allowNull: true,
|
|
52
|
-
field: 'deleted_by',
|
|
53
|
-
},
|
|
54
|
-
createdAt: {
|
|
55
|
-
type: Sequelize.DATE,
|
|
56
|
-
allowNull: false,
|
|
57
|
-
field: 'created_at',
|
|
58
|
-
},
|
|
59
|
-
updatedAt: {
|
|
60
|
-
type: Sequelize.DATE,
|
|
61
|
-
allowNull: false,
|
|
62
|
-
field: 'updated_at',
|
|
63
|
-
},
|
|
64
|
-
deletedAt: {
|
|
65
|
-
type: Sequelize.DATE,
|
|
66
|
-
allowNull: true,
|
|
67
|
-
field: 'deleted_at',
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
const tableDefinition = await queryInterface.describeTable(tableName);
|
|
73
|
-
const columnsToAdd = {
|
|
74
|
-
id: {
|
|
75
|
-
type: Sequelize.UUID,
|
|
76
|
-
defaultValue: Sequelize.UUIDV4,
|
|
77
|
-
allowNull: false,
|
|
78
|
-
primaryKey: true,
|
|
79
|
-
},
|
|
80
|
-
key: {
|
|
81
|
-
type: Sequelize.STRING,
|
|
82
|
-
allowNull: false,
|
|
83
|
-
unique: true,
|
|
84
|
-
},
|
|
85
|
-
hasValue: {
|
|
86
|
-
type: Sequelize.STRING,
|
|
87
|
-
allowNull: false,
|
|
88
|
-
field: 'has_value',
|
|
89
|
-
},
|
|
90
|
-
type: {
|
|
91
|
-
type: Sequelize.STRING,
|
|
92
|
-
allowNull: false,
|
|
93
|
-
},
|
|
94
|
-
description: {
|
|
95
|
-
type: Sequelize.TEXT,
|
|
96
|
-
allowNull: false,
|
|
97
|
-
},
|
|
98
|
-
version: {
|
|
99
|
-
type: Sequelize.INTEGER,
|
|
100
|
-
allowNull: false,
|
|
101
|
-
defaultValue: 1,
|
|
102
|
-
},
|
|
103
|
-
createdBy: {
|
|
104
|
-
type: Sequelize.UUID,
|
|
105
|
-
allowNull: true,
|
|
106
|
-
field: 'created_by',
|
|
107
|
-
},
|
|
108
|
-
updatedBy: {
|
|
109
|
-
type: Sequelize.UUID,
|
|
110
|
-
allowNull: true,
|
|
111
|
-
field: 'updated_by',
|
|
112
|
-
},
|
|
113
|
-
deletedBy: {
|
|
114
|
-
type: Sequelize.UUID,
|
|
115
|
-
allowNull: true,
|
|
116
|
-
field: 'deleted_by',
|
|
117
|
-
},
|
|
118
|
-
createdAt: {
|
|
119
|
-
type: Sequelize.DATE,
|
|
120
|
-
allowNull: false,
|
|
121
|
-
field: 'created_at',
|
|
122
|
-
},
|
|
123
|
-
updatedAt: {
|
|
124
|
-
type: Sequelize.DATE,
|
|
125
|
-
allowNull: false,
|
|
126
|
-
field: 'updated_at',
|
|
127
|
-
},
|
|
128
|
-
deletedAt: {
|
|
129
|
-
type: Sequelize.DATE,
|
|
130
|
-
allowNull: true,
|
|
131
|
-
field: 'deleted_at',
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
for (const column of Object.keys(columnsToAdd)) {
|
|
135
|
-
const columnToAdd = columnsToAdd[column];
|
|
136
|
-
const tableColumn = columnToAdd.field || column;
|
|
137
|
-
if (!tableDefinition[tableColumn]) {
|
|
138
|
-
await queryInterface.addColumn(tableName, tableColumn, columnToAdd);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
const down = async (queryInterface) => {
|
|
144
|
-
const tableName = 'ai_model_keys';
|
|
145
|
-
const tableExists = await queryInterface
|
|
146
|
-
.describeTable(tableName)
|
|
147
|
-
.then(() => true)
|
|
148
|
-
.catch(() => false);
|
|
149
|
-
if (tableExists) {
|
|
150
|
-
await queryInterface.dropTable(tableName);
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
module.exports = {
|
|
154
|
-
up,
|
|
155
|
-
down,
|
|
156
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
module.exports = {
|
|
3
|
-
up: async (queryInterface, Sequelize) => {
|
|
4
|
-
const table = await queryInterface.describeTable('categories');
|
|
5
|
-
if (!table.type) {
|
|
6
|
-
await queryInterface.addColumn('categories', 'type', {
|
|
7
|
-
type: Sequelize.STRING,
|
|
8
|
-
allowNull: true,
|
|
9
|
-
defaultValue: 'INVENTORY',
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
down: async (queryInterface, Sequelize) => {
|
|
14
|
-
const table = await queryInterface.describeTable('categories');
|
|
15
|
-
if (table.type) {
|
|
16
|
-
await queryInterface.removeColumn('categories', 'type');
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
module.exports = {
|
|
3
|
-
up: async (queryInterface, Sequelize) => {
|
|
4
|
-
const table = await queryInterface.describeTable('sub_categories');
|
|
5
|
-
if (!table.type) {
|
|
6
|
-
await queryInterface.addColumn('sub_categories', 'type', {
|
|
7
|
-
type: Sequelize.STRING,
|
|
8
|
-
allowNull: true,
|
|
9
|
-
defaultValue: 'INVENTORY',
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
down: async (queryInterface, Sequelize) => {
|
|
14
|
-
const table = await queryInterface.describeTable('sub_categories');
|
|
15
|
-
if (table.type) {
|
|
16
|
-
await queryInterface.removeColumn('sub_categories', 'type');
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
module.exports = {
|
|
3
|
-
up: async (queryInterface, Sequelize) => {
|
|
4
|
-
const table = await queryInterface.describeTable('users');
|
|
5
|
-
if (!table.status) {
|
|
6
|
-
await queryInterface.addColumn('users', 'status', {
|
|
7
|
-
type: Sequelize.STRING,
|
|
8
|
-
allowNull: true,
|
|
9
|
-
defaultValue: 'ACTIVE',
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
down: async (queryInterface, Sequelize) => {
|
|
14
|
-
const table = await queryInterface.describeTable('users');
|
|
15
|
-
if (table.status) {
|
|
16
|
-
await queryInterface.removeColumn('users', 'status');
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
};
|
package/dist/db/psql/migrations/20260721000001-add-deleted-at-to-rms-maintenance-activities.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
module.exports = {
|
|
3
|
-
up: async (queryInterface, Sequelize) => {
|
|
4
|
-
await queryInterface.addColumn('rms_maintenance_activities', 'deleted_at', {
|
|
5
|
-
type: Sequelize.DATE,
|
|
6
|
-
allowNull: true,
|
|
7
|
-
});
|
|
8
|
-
},
|
|
9
|
-
down: async (queryInterface, Sequelize) => {
|
|
10
|
-
await queryInterface.removeColumn('rms_maintenance_activities', 'deleted_at');
|
|
11
|
-
}
|
|
12
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
module.exports = {
|
|
3
|
-
up: async (queryInterface, Sequelize) => {
|
|
4
|
-
const table = await queryInterface.describeTable('file_storage');
|
|
5
|
-
if (table.uploaded_from) {
|
|
6
|
-
// In PostgreSQL, changing from ENUM to VARCHAR requires a USING clause
|
|
7
|
-
try {
|
|
8
|
-
await queryInterface.sequelize.query('ALTER TABLE file_storage ALTER COLUMN uploaded_from TYPE VARCHAR(255) USING uploaded_from::varchar;');
|
|
9
|
-
await queryInterface.changeColumn('file_storage', 'uploaded_from', {
|
|
10
|
-
type: Sequelize.STRING,
|
|
11
|
-
allowNull: true,
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
catch (error) {
|
|
15
|
-
// Fallback if the raw query fails
|
|
16
|
-
await queryInterface.changeColumn('file_storage', 'uploaded_from', {
|
|
17
|
-
type: Sequelize.STRING,
|
|
18
|
-
allowNull: true,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
down: async (queryInterface, Sequelize) => {
|
|
24
|
-
const table = await queryInterface.describeTable('file_storage');
|
|
25
|
-
if (table.uploaded_from) {
|
|
26
|
-
try {
|
|
27
|
-
await queryInterface.sequelize.query('ALTER TABLE file_storage ALTER COLUMN uploaded_from TYPE "enum_file_storage_uploaded_from" USING uploaded_from::text::"enum_file_storage_uploaded_from";');
|
|
28
|
-
await queryInterface.changeColumn('file_storage', 'uploaded_from', {
|
|
29
|
-
type: Sequelize.ENUM('INSTITUTE_APP', 'SCHOOL_APP', 'GLOBAL_APP', 'STUDENT_APP', 'VENDOR_APP'),
|
|
30
|
-
allowNull: false,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
// Fallback
|
|
35
|
-
await queryInterface.changeColumn('file_storage', 'uploaded_from', {
|
|
36
|
-
type: Sequelize.ENUM('INSTITUTE_APP', 'SCHOOL_APP', 'GLOBAL_APP', 'STUDENT_APP', 'VENDOR_APP'),
|
|
37
|
-
allowNull: false,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|