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

const TournamentStage = sequelize.define('TournamentStage', {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true,
        allowNull: false,
    },
    tournamentId: {
        type: DataTypes.INTEGER,
        allowNull: false,
    },
    index: {
        type: DataTypes.INTEGER,
        allowNull: false,
    field: 'stage_index',
    },
    name: {
        type: DataTypes.STRING,
        allowNull: true,
    },
    type: {
        type: DataTypes.STRING,
        allowNull: false, // 'groups' | 'knockout'
    },
    numberOfGroups: {
        type: DataTypes.INTEGER,
        allowNull: true,
    },
    advancingPerGroup: {
        type: DataTypes.INTEGER,
        allowNull: true,
    },
    maxGroupSize: {
        type: DataTypes.INTEGER,
        allowNull: true,
    },
}, {
    underscored: true,
    tableName: 'tournament_stage',
    timestamps: true,
});

export default TournamentStage;
