<?php
declare(strict_types=1);

return [
    'up' => "
CREATE TABLE IF NOT EXISTS sa_training_attendance (
    id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    group_id BIGINT UNSIGNED NOT NULL,
    player_id BIGINT UNSIGNED NOT NULL,
    session_date DATE NOT NULL,
    day_of_week TINYINT UNSIGNED NOT NULL COMMENT '0=Sun,1=Mon...6=Sat',
    schedule_id BIGINT UNSIGNED NULL COMMENT 'ref sa_group_schedule',
    status ENUM('present','absent','excused','late','makeup') NOT NULL DEFAULT 'absent',
    check_in_time TIME NULL,
    check_out_time TIME NULL,
    excuse_reason VARCHAR(500) NULL,
    makeup_session_id BIGINT UNSIGNED NULL COMMENT 'ref sa_makeup_sessions if status=makeup',
    recorded_by BIGINT UNSIGNED NULL,
    notes TEXT NULL,
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    INDEX idx_ta_group_date (group_id, session_date),
    INDEX idx_ta_player_date (player_id, session_date),
    INDEX idx_ta_status (status),
    UNIQUE KEY uq_ta_player_session (group_id, player_id, session_date)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
    'down' => "DROP TABLE IF EXISTS sa_training_attendance"
];
