<?php
declare(strict_types=1);

return [
    'up' => "CREATE TABLE `sa_pool_zone_template_entries` (
    `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `template_id` BIGINT UNSIGNED NOT NULL,
    `day_of_week` TINYINT UNSIGNED NOT NULL COMMENT '0=Sunday...6=Saturday',
    `start_time` TIME NOT NULL,
    `end_time` TIME NOT NULL,
    `zone_selection_type` VARCHAR(20) NOT NULL COMMENT 'cells, row, column, all',
    `zone_selection_json` JSON NOT NULL,
    `assignment_type` VARCHAR(20) NOT NULL COMMENT 'training, blocked, maintenance, hourly',
    `group_id` BIGINT UNSIGNED NULL,
    `coach_id` BIGINT UNSIGNED NULL,
    `label` VARCHAR(200) NULL,
    `notes` TEXT NULL,
    `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    INDEX `idx_sa_pzte_template` (`template_id`),
    INDEX `idx_sa_pzte_day` (`day_of_week`, `start_time`),
    CONSTRAINT `fk_sa_pzte_template` FOREIGN KEY (`template_id`) REFERENCES `sa_pool_zone_templates`(`id`) ON DELETE CASCADE,
    CONSTRAINT `fk_sa_pzte_group` FOREIGN KEY (`group_id`) REFERENCES `sa_groups`(`id`) ON DELETE SET NULL,
    CONSTRAINT `fk_sa_pzte_coach` FOREIGN KEY (`coach_id`) REFERENCES `sa_coaches`(`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",
    'down' => "DROP TABLE IF EXISTS `sa_pool_zone_template_entries`;",
];
