<?php
require 'db.php';

try {
    $sql = "
    CREATE TABLE IF NOT EXISTS 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;

    INSERT IGNORE INTO site_config (setting_key, setting_value, description) VALUES 
    ('diamond_exchange_rate', '0.01', 'Value of 1 Diamond in USD'),
    ('min_withdrawal_diamonds', '100', 'Minimum diamonds required to withdraw'),
    ('withdrawal_fee_percent', '0', 'Percentage fee for withdrawals'),
    ('sales_fee_percent', '10', 'Percentage fee for marketplace sales');
    ";

    $pdo->exec($sql);
    echo "Table site_config created and initialized successfully.";

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