<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `academy_schedules` (
            `id`              BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `academy_id`      BIGINT UNSIGNED NOT NULL,
            `level_id`        BIGINT UNSIGNED NULL,
            `facility_id`     BIGINT UNSIGNED NULL,
            `day_of_week`     TINYINT UNSIGNED NOT NULL COMMENT '0=Sun, 1=Mon, ..., 6=Sat',
            `start_time`      TIME NOT NULL,
            `end_time`        TIME NOT NULL,
            `coach_name`      VARCHAR(200) NULL,
            `season`          VARCHAR(20) NULL COMMENT 'e.g. 2025-2026',
            `is_active`       TINYINT(1) NOT NULL DEFAULT 1,
            `created_at`      TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            `updated_at`      TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
            INDEX `idx_academy_schedules_academy` (`academy_id`),
            INDEX `idx_academy_schedules_level` (`level_id`),
            INDEX `idx_academy_schedules_facility` (`facility_id`),
            INDEX `idx_academy_schedules_day` (`day_of_week`, `start_time`),
            CONSTRAINT `fk_academy_schedules_academy` FOREIGN KEY (`academy_id`) REFERENCES `academies`(`id`) ON DELETE CASCADE,
            CONSTRAINT `fk_academy_schedules_level` FOREIGN KEY (`level_id`) REFERENCES `academy_levels`(`id`) ON DELETE SET NULL,
            CONSTRAINT `fk_academy_schedules_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 `academy_schedules`",
];
