<?php
declare(strict_types=1);

return [
    'up' => "CREATE TABLE IF NOT EXISTS `session_attendance` (
    `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `session_id` BIGINT UNSIGNED NOT NULL,
    `player_id` BIGINT UNSIGNED NOT NULL,
    `enrollment_id` BIGINT UNSIGNED NULL,
    `status` VARCHAR(20) NOT NULL DEFAULT 'present' COMMENT 'present, absent, late, excused, makeup',
    `check_in_time` TIME NULL,
    `check_out_time` TIME NULL,
    `is_makeup` TINYINT(1) NOT NULL DEFAULT 0,
    `makeup_for_session_id` BIGINT UNSIGNED NULL,
    `notes` TEXT NULL,
    `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `created_by` BIGINT UNSIGNED NULL,
    UNIQUE KEY `uq_sa_session_player` (`session_id`, `player_id`),
    INDEX `idx_sa_player` (`player_id`),
    INDEX `idx_sa_status` (`status`),
    CONSTRAINT `fk_sa_session` FOREIGN KEY (`session_id`) REFERENCES `training_sessions`(`id`) ON DELETE CASCADE,
    CONSTRAINT `fk_sa_player` FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE,
    CONSTRAINT `fk_sa_enrollment` FOREIGN KEY (`enrollment_id`) REFERENCES `academy_enrollments`(`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
    'down' => "DROP TABLE IF EXISTS `session_attendance`",
];
