<?php
declare(strict_types=1);

return [
    'up' => "CREATE TABLE IF NOT EXISTS `facility_zone_schedules` (
    `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `grid_id` BIGINT UNSIGNED NOT NULL,
    `schedule_name` VARCHAR(255) NOT NULL,
    `zone_selection_type` VARCHAR(20) NOT NULL COMMENT 'cells, row, column, all',
    `zone_selection_json` JSON NOT NULL COMMENT 'selected positions',
    `day_of_week` TINYINT UNSIGNED NOT NULL COMMENT '0=Sun...6=Sat',
    `start_time` TIME NOT NULL,
    `end_time` TIME NOT NULL,
    `activity_type` VARCHAR(30) NULL,
    `coach_id` BIGINT UNSIGNED NULL,
    `coach_name` VARCHAR(200) NULL,
    `academy_id` BIGINT UNSIGNED NULL,
    `academy_name` VARCHAR(200) NULL,
    `age_group` VARCHAR(50) NULL,
    `gender` VARCHAR(10) NULL DEFAULT 'mixed',
    `max_occupants` INT UNSIGNED NOT NULL DEFAULT 8,
    `color` VARCHAR(20) NULL DEFAULT '#3B82F6',
    `effective_from` DATE NOT NULL,
    `effective_to` DATE NULL,
    `is_active` TINYINT(1) NOT NULL DEFAULT 1,
    `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_fzs_grid` (`grid_id`),
    INDEX `idx_fzs_day` (`day_of_week`),
    INDEX `idx_fzs_active` (`is_active`, `effective_from`, `effective_to`),
    CONSTRAINT `fk_fzs_grid` FOREIGN KEY (`grid_id`) REFERENCES `facility_grids`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
    'down' => "DROP TABLE IF EXISTS `facility_zone_schedules`",
];
