<?php
declare(strict_types=1);

return [
    'up' => "
CREATE TABLE IF NOT EXISTS session_feedback (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    session_id INT UNSIGNED NOT NULL,
    player_id INT UNSIGNED NOT NULL,
    rating TINYINT UNSIGNED NOT NULL DEFAULT 3 COMMENT '1-5',
    energy_level ENUM('low','medium','high') NOT NULL DEFAULT 'medium',
    enjoyment_level TINYINT UNSIGNED NOT NULL DEFAULT 3,
    difficulty_level TINYINT UNSIGNED NOT NULL DEFAULT 3,
    comments_ar TEXT NULL,
    is_anonymous TINYINT(1) NOT NULL DEFAULT 0,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    INDEX idx_session (session_id),
    INDEX idx_player (player_id),
    UNIQUE KEY uk_session_player (session_id, player_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS group_waitlist (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    group_id INT UNSIGNED NOT NULL,
    player_id INT UNSIGNED NOT NULL,
    priority INT UNSIGNED NOT NULL DEFAULT 0,
    status ENUM('waiting','offered','accepted','expired','cancelled') NOT NULL DEFAULT 'waiting',
    requested_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    offered_at DATETIME NULL,
    expires_at DATETIME NULL,
    accepted_at DATETIME NULL,
    notes TEXT NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    INDEX idx_group_status (group_id, status),
    INDEX idx_player (player_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
",
    'down' => "
DROP TABLE IF EXISTS group_waitlist;
DROP TABLE IF EXISTS session_feedback
",
];
