const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');

const EventTeamMember = sequelize.define('EventTeamMember', {
  eventTeamId: {
    type: DataTypes.INTEGER.UNSIGNED,
    allowNull: false,
    primaryKey: true,
    comment: '이벤트 팀 ID'
  },
  eventParticipantId: {
    type: DataTypes.INTEGER.UNSIGNED,
    allowNull: false,
    primaryKey: true,
    comment: '이벤트 참가자 ID'
  },
  order: {
    type: DataTypes.INTEGER.UNSIGNED,
    allowNull: false,
    defaultValue: 1,
    comment: '팀 내 순번'
  }
}, {
  tableName: 'EventTeamMembers',
  comment: '이벤트 팀별 멤버 정보를 저장하는 테이블',
  timestamps: false
});

EventTeamMember.associate = (models) => {
  EventTeamMember.belongsTo(models.EventTeam, { foreignKey: 'eventTeamId' });
  EventTeamMember.belongsTo(models.EventParticipant, { foreignKey: 'eventParticipantId' });
};

module.exports = EventTeamMember;
