const { DataTypes } = require('sequelize'); const { sequelize } = require('../config/database'); const Notification = sequelize.define('Notification', { id: { type: DataTypes.INTEGER.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '알림 고유 식별자' }, userId: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, references: { model: 'Users', key: 'id' }, comment: '유저 ID' }, title: { type: DataTypes.STRING, allowNull: false, comment: '알림 제목' }, message: { type: DataTypes.TEXT, allowNull: false, comment: '알림 내용' }, icon: { type: DataTypes.STRING, defaultValue: 'pi pi-info-circle', comment: '아이콘' }, type: { type: DataTypes.ENUM('info', 'success', 'warning', 'error'), defaultValue: 'info', comment: '알림 타입' }, read: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false, comment: '읽음 여부' }, link: { type: DataTypes.STRING, allowNull: true, defaultValue: null, comment: '관련 링크' }, createdAt: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW, comment: '생성일' }, updatedAt: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW, comment: '수정일' } }, { timestamps: true, comment: '유저 알림 정보를 저장하는 테이블', tableName: 'Notifications' }); Notification.associate = (models) => { Notification.belongsTo(models.User, { foreignKey: 'userId' }); }; module.exports = Notification;