const { DataTypes } = require('sequelize'); const { sequelize } = require('../config/database'); const EventParticipant = sequelize.define('EventParticipant', { id: { type: DataTypes.INTEGER.UNSIGNED, primaryKey: true, autoIncrement: true }, eventId: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, references: { model: 'Events', key: 'id' } }, memberId: { type: DataTypes.INTEGER.UNSIGNED, allowNull: false, references: { model: 'Members', key: 'id' } }, teamId: { type: DataTypes.INTEGER.UNSIGNED, allowNull: true, references: { model: 'EventTeams', key: 'id' } }, status: { type: DataTypes.ENUM('참가예정', '참가확정', '취소'), allowNull: false, defaultValue: '참가예정' }, paymentStatus: { type: DataTypes.ENUM('미납', '납부완료'), allowNull: false, defaultValue: '미납' } }, { tableName: 'EventParticipants', timestamps: true }); // 관계 설정 EventParticipant.associate = (models) => { EventParticipant.belongsTo(models.Event, { foreignKey: 'eventId' }); EventParticipant.belongsTo(models.Member, { foreignKey: 'memberId' }); EventParticipant.belongsTo(models.EventTeam, { foreignKey: 'teamId' }); EventParticipant.hasMany(models.EventScore, { foreignKey: 'participantId' }); }; EventParticipant.associate = (models) => { EventParticipant.hasMany(models.EventScore, { foreignKey: 'participantId' }); }; module.exports = EventParticipant;