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

const TournamentStageAdvancement = sequelize.define('TournamentStageAdvancement', {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true,
        allowNull: false,
    },
    tournamentId: {
        type: DataTypes.INTEGER,
        allowNull: false,
    },
    fromStageId: {
        type: DataTypes.INTEGER,
        allowNull: false,
    },
    toStageId: {
        type: DataTypes.INTEGER,
        allowNull: false,
    },
    mode: {
        type: DataTypes.STRING,
        allowNull: false,
        defaultValue: 'pools',
    },
    config: {
        // JSON: { pools: [{ fromPlaces:[1,2], target:{ type:'groups', groupCount:2 }}, ...] }
        type: DataTypes.JSON,
        allowNull: false,
        defaultValue: {},
    },
}, {
    underscored: true,
    tableName: 'tournament_stage_advancement',
    timestamps: true,
});

export default TournamentStageAdvancement;
