const { DataTypes } = require('sequelize'); const { sequelize } = require('../config/database'); const Event = sequelize.define('Event', { id: { type: DataTypes.INTEGER.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '이벤트 고유 식별자' }, clubId: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, references: { model: 'Clubs', key: 'id' }, comment: '소속 클럽 ID' }, title: { type: DataTypes.STRING, allowNull: false, comment: '이벤트 제목' }, description: { type: DataTypes.TEXT, allowNull: true, comment: '이벤트 설명' }, eventType: { type: DataTypes.ENUM('정기전', '번개', '연습', '교류전', '이벤트', '기타'), allowNull: false, defaultValue: '정기전', comment: '이벤트 유형' }, startDate: { type: DataTypes.DATE, allowNull: false, comment: '시작일' }, endDate: { type: DataTypes.DATE, allowNull: true, comment: '종료일' }, location: { type: DataTypes.STRING, allowNull: true, comment: '장소' }, gameCount: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 3, comment: '게임 수' }, participantFee: { type: DataTypes.DECIMAL(10, 2), allowNull: false, defaultValue: 0, comment: '참가비' }, maxParticipants: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 0, comment: '최대 참가 인원' }, registrationDeadline: { type: DataTypes.DATE, allowNull: true, comment: '참가 신청 마감일' }, participantCount: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 0, comment: '참가자 수' }, status: { type: DataTypes.ENUM('준비', '활성', '완료', '취소', '삭제'), allowNull: false, defaultValue: '활성', comment: '이벤트 상태' }, createdAt: { type: DataTypes.DATE, allowNull: false, comment: '생성일' }, updatedAt: { type: DataTypes.DATE, allowNull: false, comment: '수정일' } }, { tableName: 'Events', comment: '클럽 내 이벤트(대회, 모임 등) 정보를 저장하는 테이블', timestamps: true }); // 관계 설정 Event.associate = (models) => { Event.belongsTo(models.Club, { foreignKey: 'clubId' }); Event.hasMany(models.EventParticipant, { foreignKey: 'eventId' }); Event.hasMany(models.EventScore, { foreignKey: 'eventId' }); }; module.exports = Event;