const { DataTypes } = require('sequelize'); const { sequelize } = require('../config/database'); const Notification = sequelize.define('Notification', { id: { type: DataTypes.INTEGER.UNSIGNED, primaryKey: true, autoIncrement: true }, userId: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, references: { model: 'Users', key: 'id' } }, title: { type: DataTypes.STRING, allowNull: false }, message: { type: DataTypes.TEXT, allowNull: false }, icon: { type: DataTypes.STRING, defaultValue: 'pi pi-info-circle' }, type: { type: DataTypes.ENUM('info', 'success', 'warning', 'error'), defaultValue: 'info' }, read: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false }, link: { type: DataTypes.STRING, allowNull: true, defaultValue: null }, createdAt: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW }, updatedAt: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW } }, { timestamps: true, tableName: 'Notifications' }); Notification.associate = (models) => { Notification.belongsTo(models.User, { foreignKey: 'userId' }); }; module.exports = Notification;