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

try {
    $pdo->exec("ALTER TABLE users ADD COLUMN IF NOT EXISTS redirect_url VARCHAR(500) DEFAULT NULL");
    $pdo->exec("ALTER TABLE users ADD COLUMN IF NOT EXISTS phone VARCHAR(20) DEFAULT NULL");
    $pdo->exec("ALTER TABLE users ADD COLUMN IF NOT EXISTS role ENUM('user','admin') DEFAULT 'user'");
    $pdo->exec("ALTER TABLE users ADD COLUMN IF NOT EXISTS landing_page VARCHAR(50) DEFAULT 'landing1'");
    $pdo->exec("ALTER TABLE users ADD COLUMN IF NOT EXISTS webhook_token VARCHAR(64) DEFAULT NULL");
    
    $pdo->exec("ALTER TABLE videos ADD COLUMN IF NOT EXISTS position INT DEFAULT NULL");
    $pdo->exec("ALTER TABLE videos ADD COLUMN IF NOT EXISTS fake_views INT DEFAULT 0");

    echo "✅ Database schema updated successfully.\n";
} catch (PDOException $e) {
    echo "❌ Error updating database: " . $e->getMessage() . "\n";
}

