<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `evaluation_criteria` (
            `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `discipline_id` BIGINT UNSIGNED NOT NULL,
            `criterion_name_ar` VARCHAR(200) NOT NULL,
            `criterion_name_en` VARCHAR(200) NULL,
            `description_ar` TEXT NULL,
            `max_score` INT NOT NULL DEFAULT 10,
            `weight` DECIMAL(3,2) NOT NULL DEFAULT 1.00,
            `sort_order` INT NOT NULL DEFAULT 0,
            `is_active` TINYINT(1) NOT NULL DEFAULT 1,
            `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
            INDEX `idx_ec_discipline` (`discipline_id`),
            INDEX `idx_ec_active` (`is_active`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

        CREATE TABLE IF NOT EXISTS `player_evaluations` (
            `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `player_id` BIGINT UNSIGNED NOT NULL,
            `discipline_id` BIGINT UNSIGNED NOT NULL,
            `session_id` BIGINT UNSIGNED NULL,
            `evaluator_coach_id` BIGINT UNSIGNED NULL,
            `evaluation_date` DATE NOT NULL,
            `overall_score` DECIMAL(5,2) NULL,
            `skill_level` VARCHAR(20) NULL COMMENT 'beginner, intermediate, advanced, elite',
            `recommended_group_type` VARCHAR(20) NULL,
            `recommended_group_id` BIGINT UNSIGNED NULL,
            `scores_json` JSON NOT NULL COMMENT '[{criterion_id, score, notes}]',
            `strengths_ar` TEXT NULL,
            `weaknesses_ar` TEXT NULL,
            `coach_notes` TEXT NULL,
            `parent_visible` TINYINT(1) NOT NULL DEFAULT 1,
            `status` VARCHAR(20) NOT NULL DEFAULT 'draft' COMMENT 'draft, submitted, approved',
            `approved_by` BIGINT UNSIGNED NULL,
            `approved_at` DATETIME NULL,
            `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
            `created_by` BIGINT UNSIGNED NULL,
            INDEX `idx_pe_player` (`player_id`),
            INDEX `idx_pe_discipline` (`discipline_id`),
            INDEX `idx_pe_coach` (`evaluator_coach_id`),
            INDEX `idx_pe_date` (`evaluation_date`),
            INDEX `idx_pe_status` (`status`),
            CONSTRAINT `fk_pe_player` FOREIGN KEY (`player_id`) REFERENCES `players`(`id`),
            CONSTRAINT `fk_pe_coach` FOREIGN KEY (`evaluator_coach_id`) REFERENCES `coaches`(`id`) ON DELETE SET NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "
        DROP TABLE IF EXISTS `player_evaluations`;
        DROP TABLE IF EXISTS `evaluation_criteria`
    ",
];
