<?php
declare(strict_types=1);

/**
 * Creates the session_feedback table for the Session Feedback System.
 * Note: This table may already exist from Phase_63_012. This migration uses IF NOT EXISTS.
 */
return [
    'up' => "
        CREATE TABLE IF NOT EXISTS `session_feedback` (
            `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            `session_id` BIGINT UNSIGNED NOT NULL,
            `player_id` BIGINT UNSIGNED NOT NULL,
            `rating` TINYINT UNSIGNED NOT NULL COMMENT '1-5',
            `energy_level` ENUM('low','medium','high') NOT NULL DEFAULT 'medium',
            `enjoyment_level` TINYINT UNSIGNED NOT NULL DEFAULT 3 COMMENT '1-5',
            `difficulty_level` TINYINT UNSIGNED NOT NULL DEFAULT 3 COMMENT '1-5',
            `comments_ar` TEXT NULL,
            `is_anonymous` TINYINT(1) NOT NULL DEFAULT 0,
            `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
            INDEX `idx_sf_session` (`session_id`),
            INDEX `idx_sf_player` (`player_id`),
            INDEX `idx_sf_rating` (`rating`),
            UNIQUE KEY `uk_sf_session_player` (`session_id`, `player_id`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    ",
    'down' => "
        DROP TABLE IF EXISTS `session_feedback`
    ",
];
