<?php
declare(strict_types=1);
return [
    'up' => "CREATE TABLE IF NOT EXISTS `players` (
    `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `player_type` VARCHAR(20) NOT NULL COMMENT 'member, non_member',
    `member_id` BIGINT UNSIGNED NULL COMMENT 'FK to members for member players',
    `activity_id_number` VARCHAR(50) NULL COMMENT 'Sports activity ID card number',
    `registration_serial` VARCHAR(50) NULL COMMENT 'Auto-generated serial',
    `full_name_ar` VARCHAR(300) NOT NULL,
    `full_name_en` VARCHAR(300) NULL,
    `national_id` VARCHAR(20) NULL,
    `passport_number` VARCHAR(50) NULL,
    `date_of_birth` DATE NULL,
    `gender` VARCHAR(10) NULL COMMENT 'male, female',
    `phone` VARCHAR(30) NULL,
    `email` VARCHAR(200) NULL,
    `address` TEXT NULL,
    `guardian_name` VARCHAR(300) NULL,
    `guardian_phone` VARCHAR(30) NULL,
    `guardian_national_id` VARCHAR(20) NULL,
    `guardian_relationship` VARCHAR(50) NULL COMMENT 'father, mother, brother, sister, other',
    `photo_path` VARCHAR(500) NULL,
    `medical_status` VARCHAR(30) NULL DEFAULT 'pending' COMMENT 'pending, fit, conditional, unfit, expired',
    `medical_expiry_date` DATE NULL,
    `school_name` VARCHAR(300) NULL,
    `school_grade` VARCHAR(100) NULL,
    `registration_fee_paid` TINYINT(1) NOT NULL DEFAULT 0,
    `card_status` VARCHAR(20) NOT NULL DEFAULT 'inactive' COMMENT 'inactive, active, suspended, revoked',
    `access_window_minutes` INT UNSIGNED NULL COMMENT '30 for non-members',
    `notes` TEXT NULL,
    `branch_id` BIGINT UNSIGNED NULL,
    `is_archived` TINYINT(1) NOT NULL DEFAULT 0,
    `archived_at` TIMESTAMP NULL DEFAULT NULL,
    `archived_by` BIGINT UNSIGNED 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,
    `updated_by` BIGINT UNSIGNED NULL,
    UNIQUE KEY `uq_players_registration_serial` (`registration_serial`),
    INDEX `idx_players_type` (`player_type`),
    INDEX `idx_players_member` (`member_id`),
    INDEX `idx_players_national_id` (`national_id`),
    INDEX `idx_players_card_status` (`card_status`),
    INDEX `idx_players_medical_status` (`medical_status`),
    INDEX `idx_players_branch` (`branch_id`),
    CONSTRAINT `fk_players_member` FOREIGN KEY (`member_id`) REFERENCES `members`(`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
    'down' => "DROP TABLE IF EXISTS `players`",
];
