<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE `sa_attendance` (
            `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `booking_id` BIGINT UNSIGNED NOT NULL,
            `player_id` BIGINT UNSIGNED NOT NULL,
            `attendance_date` DATE NOT NULL,
            `status` VARCHAR(20) NOT NULL DEFAULT 'present' COMMENT 'present, absent, late, excused',
            `check_in_time` TIME NULL,
            `check_out_time` TIME NULL,
            `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,
            UNIQUE KEY `uq_sa_att_record` (`booking_id`, `player_id`, `attendance_date`),
            INDEX `idx_sa_att_player` (`player_id`),
            INDEX `idx_sa_att_date` (`attendance_date`),
            INDEX `idx_sa_att_status` (`status`),
            CONSTRAINT `fk_sa_att_booking` FOREIGN KEY (`booking_id`) REFERENCES `sa_bookings`(`id`) ON DELETE CASCADE,
            CONSTRAINT `fk_sa_att_player` FOREIGN KEY (`player_id`) REFERENCES `sa_players`(`id`) ON DELETE CASCADE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `sa_attendance`",
];
