<?php
declare(strict_types=1);
return [
    'up' => "CREATE TABLE IF NOT EXISTS `player_medical_records` (
    `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `player_id` BIGINT UNSIGNED NOT NULL,
    `record_type` VARCHAR(50) NOT NULL COMMENT 'fitness_cert, medical_exam, blood_test, cardiac_screen, other',
    `exam_date` DATE NULL,
    `expiry_date` DATE NULL,
    `doctor_name` VARCHAR(200) NULL,
    `clinic_name` VARCHAR(200) NULL,
    `result` VARCHAR(30) NULL COMMENT 'fit, conditional, unfit',
    `restrictions` TEXT NULL COMMENT 'Any medical restrictions',
    `document_id` BIGINT UNSIGNED NULL COMMENT 'FK to documents table for uploaded file',
    `notes` TEXT 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_pmr_player` (`player_id`),
    INDEX `idx_pmr_expiry` (`expiry_date`),
    INDEX `idx_pmr_result` (`result`),
    CONSTRAINT `fk_pmr_player` FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE,
    CONSTRAINT `fk_pmr_document` FOREIGN KEY (`document_id`) REFERENCES `documents`(`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
    'down' => "DROP TABLE IF EXISTS `player_medical_records`",
];
