<?php
require_once __DIR__ . '/../config/config.php';
$db = Database::getInstance();
try {
    $col = $db->fetch("SHOW TABLES LIKE 'survey_responses'");
    if ($col) {
        echo "Table survey_responses already exists\n";
        exit;
    }

    $sql = "CREATE TABLE survey_responses (
        id INT AUTO_INCREMENT PRIMARY KEY,
        user_id INT NULL,
        phone_number VARCHAR(30) NULL,
        q_easy_interact TINYINT(1) NULL,
        q_human_resolved TINYINT(1) NULL,
        rating INT NULL,
        comment TEXT NULL,
        raw_text TEXT NULL,
        created_at DATETIME NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4";

    $db->query($sql);
    echo "Created table survey_responses\n";
} catch (Exception $e) {
    echo "Failed creating survey_responses: " . $e->getMessage() . "\n";
}
