<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `player_injuries` (
            `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `player_id` BIGINT UNSIGNED NOT NULL,
            `discipline_id` BIGINT UNSIGNED NULL,
            `injury_type` VARCHAR(50) NOT NULL COMMENT 'muscle, bone, joint, ligament, concussion, skin, other',
            `body_part` VARCHAR(100) NOT NULL,
            `severity` VARCHAR(20) NOT NULL COMMENT 'minor, moderate, severe, critical',
            `description_ar` TEXT NOT NULL,
            `occurred_date` DATE NOT NULL,
            `occurred_during` VARCHAR(30) NULL COMMENT 'training, match, warmup, external',
            `session_id` BIGINT UNSIGNED NULL,
            `tournament_match_id` BIGINT UNSIGNED NULL,
            `diagnosed_by` VARCHAR(200) NULL,
            `diagnosis_ar` TEXT NULL,
            `treatment_ar` TEXT NULL,
            `estimated_recovery_days` INT UNSIGNED NULL,
            `actual_recovery_date` DATE NULL,
            `status` VARCHAR(20) NOT NULL DEFAULT 'active' COMMENT 'active, recovering, recovered, chronic',
            `restricted_activities_json` JSON NULL COMMENT 'activities player cannot do during recovery',
            `follow_up_date` DATE NULL,
            `medical_report_document_id` BIGINT UNSIGNED NULL,
            `clearance_document_id` BIGINT UNSIGNED NULL,
            `cleared_by` VARCHAR(200) NULL,
            `cleared_at` DATE NULL,
            `notes` TEXT NULL,
            `reported_by` BIGINT UNSIGNED NULL,
            `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
            INDEX `idx_pi_player` (`player_id`),
            INDEX `idx_pi_status` (`status`),
            INDEX `idx_pi_date` (`occurred_date`),
            INDEX `idx_pi_severity` (`severity`),
            INDEX `idx_pi_recovery` (`actual_recovery_date`),
            CONSTRAINT `fk_pi_player` FOREIGN KEY (`player_id`) REFERENCES `players`(`id`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

        CREATE TABLE IF NOT EXISTS `player_fitness_tests` (
            `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `player_id` BIGINT UNSIGNED NOT NULL,
            `discipline_id` BIGINT UNSIGNED NULL,
            `test_date` DATE NOT NULL,
            `test_type` VARCHAR(50) NOT NULL COMMENT 'general, sport_specific, return_to_play, periodic',
            `tester_name` VARCHAR(200) NULL,
            `coach_id` BIGINT UNSIGNED NULL,
            `results_json` JSON NOT NULL COMMENT '[{test_name, value, unit, benchmark, pass}]',
            `overall_fitness_score` DECIMAL(5,2) NULL,
            `fitness_level` VARCHAR(20) NULL COMMENT 'excellent, good, average, below_average, poor',
            `bmi` DECIMAL(4,1) NULL,
            `weight_kg` DECIMAL(5,1) NULL,
            `height_cm` DECIMAL(5,1) NULL,
            `resting_heart_rate` INT UNSIGNED NULL,
            `blood_pressure` VARCHAR(20) NULL,
            `recommendations_ar` TEXT NULL,
            `cleared_for_activity` TINYINT(1) NOT NULL DEFAULT 1,
            `next_test_date` DATE NULL,
            `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            INDEX `idx_pft_player` (`player_id`),
            INDEX `idx_pft_date` (`test_date`),
            INDEX `idx_pft_type` (`test_type`),
            CONSTRAINT `fk_pft_player` FOREIGN KEY (`player_id`) REFERENCES `players`(`id`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "
        DROP TABLE IF EXISTS `player_fitness_tests`;
        DROP TABLE IF EXISTS `player_injuries`
    ",
];
