<?php
declare(strict_types=1);

return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `facility_time_slots` (
            `id`                  BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `facility_id`         BIGINT UNSIGNED NOT 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,
            `slot_type`           VARCHAR(30) NOT NULL DEFAULT 'available' COMMENT 'available, maintenance, academy_reserved, blocked',
            `linked_academy_id`   BIGINT UNSIGNED NULL,
            `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_fts_facility` (`facility_id`),
            INDEX `idx_fts_day_time` (`day_of_week`, `start_time`, `end_time`),
            CONSTRAINT `fk_fts_facility` FOREIGN KEY (`facility_id`) REFERENCES `facilities`(`id`) ON DELETE CASCADE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "DROP TABLE IF EXISTS `facility_time_slots`",
];
