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

error_reporting(E_ALL);
ini_set('display_errors', 1);

try {
    echo "Attempting to create site_config table...\n";
    $sql = "CREATE TABLE site_config (
        id INT AUTO_INCREMENT PRIMARY KEY,
        setting_key VARCHAR(50) NOT NULL UNIQUE,
        setting_value TEXT,
        description TEXT,
        updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;";
    
    $result = $pdo->exec($sql);
    echo "Result of CREATE TABLE: " . var_export($result, true) . "\n";
    
    $stmt = $pdo->query("SHOW TABLES LIKE 'site_config'");
    if ($stmt->fetch()) {
        echo "Table correctly created!\n";
    } else {
        echo "Table still does not exist after creation attempt.\n";
    }

} catch (PDOException $e) {
    echo "PDO Error: " . $e->getMessage() . "\n";
}
?>
