import { DataTypes } from 'sequelize';
import sequelize from '../database.js';

const OfficialCompetitionMember = sequelize.define('OfficialCompetitionMember', {
  id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
  tournamentId: { type: DataTypes.INTEGER, allowNull: false },
  competitionId: { type: DataTypes.INTEGER, allowNull: false },
  memberId: { type: DataTypes.INTEGER, allowNull: false },
  wants: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false },
  registered: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false },
  participated: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false },
  placement: { type: DataTypes.STRING, allowNull: true },
}, {
  tableName: 'official_competition_members',
  timestamps: true,
  underscored: true,
  indexes: [
    { unique: true, fields: ['competition_id', 'member_id'] },
    { fields: ['tournament_id'] },
  ],
});

export default OfficialCompetitionMember;


