// src/models/Alert.js const { Model, DataTypes } = require("sequelize"); class Alert extends Model { static init(sequelize) { super.init( { id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true, }, type: { type: DataTypes.ENUM("error", "warning", "info"), allowNull: false, }, message: { type: DataTypes.STRING, allowNull: false, }, read: { type: DataTypes.BOOLEAN, defaultValue: false, }, companyId: { type: DataTypes.UUID, allowNull: false, }, branchId: { type: DataTypes.UUID, allowNull: true, }, }, { sequelize, modelName: "Alert", tableName: "alerts", timestamps: true, } ); return this; } static associate(models) { this.belongsTo(models.Company, { foreignKey: "companyId" }); this.belongsTo(models.Branch, { foreignKey: "branchId" }); } } module.exports = Alert;