<?php
// create_puzzle_table.php
require 'db.php';

try {
    echo "Tworzenie tabeli solved_puzzles...\n";

    $sql = "CREATE TABLE IF NOT EXISTS solved_puzzles (
        id INT AUTO_INCREMENT PRIMARY KEY,
        guest_id INT NOT NULL,
        puzzle_id INT NOT NULL,
        solved_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
        UNIQUE KEY unique_solve (guest_id, puzzle_id)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";

    $pdo->exec($sql);
    echo "Tabela stworzona pomyślnie.\n";

} catch (PDOException $e) {
    echo "Błąd: " . $e->getMessage() . "\n";
}
?>