<?php
declare(strict_types=1);

return [
    'up' => "CREATE TABLE IF NOT EXISTS `waiting_list` (
    `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `player_id` BIGINT UNSIGNED NOT NULL,
    `discipline_id` BIGINT UNSIGNED NOT NULL,
    `level_id` BIGINT UNSIGNED NULL,
    `preferred_day_of_week` TINYINT UNSIGNED NULL,
    `preferred_time` VARCHAR(5) NULL COMMENT 'AM or PM',
    `priority` INT UNSIGNED NOT NULL DEFAULT 100,
    `requested_group_type` VARCHAR(20) NULL,
    `status` VARCHAR(20) NOT NULL DEFAULT 'waiting' COMMENT 'waiting, offered, accepted, expired, cancelled',
    `offered_group_id` BIGINT UNSIGNED NULL,
    `offered_at` TIMESTAMP NULL,
    `offer_expires_at` TIMESTAMP 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_wl_player` (`player_id`),
    INDEX `idx_wl_discipline` (`discipline_id`),
    INDEX `idx_wl_status_priority` (`status`, `priority`),
    CONSTRAINT `fk_wl_player` FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE,
    CONSTRAINT `fk_wl_discipline` FOREIGN KEY (`discipline_id`) REFERENCES `sport_disciplines`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
    'down' => "DROP TABLE IF EXISTS `waiting_list`",
];
