<?php
// upgrade_db.php
require_once 'fingerprint_wrapper.php';
header('Content-Type: text/plain');

$pdo = get_db_connection();
if (!$pdo) die("Database connection failed.\n");

try {
    // Add the new column if it doesn't exist
    $pdo->exec("ALTER TABLE traffic_logs ADD COLUMN is_proxy TINYINT(1) DEFAULT 0 AFTER destination");
    echo "SUCCESS: 'is_proxy' column added to traffic_logs table.\n";
} catch (PDOException $e) {
    if (strpos($e->getMessage(), 'Duplicate column name') !== false) {
        echo "NOTICE: Column already exists. You are good to go.\n";
    } else {
        echo "ERROR: " . $e->getMessage() . "\n";
    }
}
?>