<?php
declare(strict_types=1);

return [
    'up' => "CREATE TABLE IF NOT EXISTS `training_sessions` (
    `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `group_id` BIGINT UNSIGNED NOT NULL,
    `academy_id` BIGINT UNSIGNED NOT NULL,
    `coach_id` BIGINT UNSIGNED NULL,
    `facility_id` BIGINT UNSIGNED NULL,
    `session_date` DATE NOT NULL,
    `start_time` TIME NOT NULL,
    `end_time` TIME NOT NULL,
    `session_type` VARCHAR(20) NOT NULL DEFAULT 'regular' COMMENT 'regular, makeup, extra, assessment',
    `status` VARCHAR(20) NOT NULL DEFAULT 'scheduled' COMMENT 'scheduled, in_progress, completed, cancelled',
    `cancellation_reason` VARCHAR(500) NULL,
    `cancelled_by` BIGINT UNSIGNED NULL,
    `players_expected` INT UNSIGNED NOT NULL DEFAULT 0,
    `players_attended` INT UNSIGNED NOT NULL DEFAULT 0,
    `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_ts_group` (`group_id`),
    INDEX `idx_ts_academy` (`academy_id`),
    INDEX `idx_ts_coach` (`coach_id`),
    INDEX `idx_ts_date` (`session_date`),
    INDEX `idx_ts_status` (`status`),
    CONSTRAINT `fk_ts_group` FOREIGN KEY (`group_id`) REFERENCES `training_groups`(`id`) ON DELETE CASCADE,
    CONSTRAINT `fk_ts_academy` FOREIGN KEY (`academy_id`) REFERENCES `academies`(`id`) ON DELETE CASCADE,
    CONSTRAINT `fk_ts_coach` FOREIGN KEY (`coach_id`) REFERENCES `coaches`(`id`) ON DELETE SET NULL,
    CONSTRAINT `fk_ts_facility` FOREIGN KEY (`facility_id`) REFERENCES `facilities`(`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
    'down' => "DROP TABLE IF EXISTS `training_sessions`",
];
