<?php
declare(strict_types=1);

return [
    'up' => "CREATE TABLE IF NOT EXISTS `pool_schedules` (
    `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `pool_config_id` BIGINT UNSIGNED NOT NULL,
    `schedule_name` VARCHAR(255) 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,
    `lanes_json` JSON NOT NULL COMMENT 'array of lane numbers',
    `booking_type` VARCHAR(30) NOT NULL DEFAULT 'academy_session',
    `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' COMMENT 'boys,girls,mixed',
    `max_swimmers` 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_ps_pool` (`pool_config_id`),
    INDEX `idx_ps_day` (`day_of_week`),
    INDEX `idx_ps_active` (`is_active`, `effective_from`, `effective_to`),
    CONSTRAINT `fk_ps_pool` FOREIGN KEY (`pool_config_id`) REFERENCES `pool_configurations`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
    'down' => "DROP TABLE IF EXISTS `pool_schedules`",
];
