<?php
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/db.php';

echo "<h2>Database Migration for Seller Upgrade Requests</h2>";

$query = "CREATE TABLE IF NOT EXISTS seller_upgrade_requests (
    id INT AUTO_INCREMENT PRIMARY KEY,
    user_id INT NOT NULL,
    business_name VARCHAR(255) NOT NULL,
    business_phone VARCHAR(50) NOT NULL,
    business_description TEXT,
    business_address TEXT,
    status ENUM('Pending', 'Approved', 'Rejected') DEFAULT 'Pending',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)";

$conn = $db->getConnection();
try {
    $result = $conn->query($query);
    if ($result) {
        echo "<p style='color:green;'>Success: Table seller_upgrade_requests created or already exists.</p>";
    }
} catch (mysqli_sql_exception $e) {
    echo "<p style='color:red;'>Error executing query: " . htmlspecialchars($e->getMessage()) . "</p>";
}

echo "<br><p>Migration complete. You may delete this file.</p>";
?>
