module.exports = (sequelize, DataTypes) => { const SLAEscalationConfig = sequelize.define('SLAEscalationConfig', { id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true }, slaConfigId: { type: DataTypes.UUID, allowNull: false, references: { model: 'sla_configurations', key: 'id' } }, level: { type: DataTypes.INTEGER, allowNull: false }, timeValue: { type: DataTypes.INTEGER, allowNull: false }, timeUnit: { type: DataTypes.ENUM('hours', 'days'), allowNull: false }, notifyEmail: { type: DataTypes.STRING, allowNull: false, validate: { isEmail: true } } }, { tableName: 'sla_config_escalations', timestamps: true, indexes: [ { fields: ['slaConfigId'] } ] }); SLAEscalationConfig.associate = (models) => { SLAEscalationConfig.belongsTo(models.SLAConfiguration, { foreignKey: 'slaConfigId', as: 'slaConfig' }); }; return SLAEscalationConfig; };