<?php
require 'db.php';

try {
    echo "Updating database schema for alcohol tracking...\n";

    $columns = [
        'vodka_ml' => 'INT DEFAULT 0',
        'whisky_ml' => 'INT DEFAULT 0',
        'liqueur_ml' => 'INT DEFAULT 0'
    ];

    foreach ($columns as $col => $def) {
        try {
            $pdo->query("SELECT $col FROM guests LIMIT 1");
            echo "Column $col already exists.\n";
        } catch (Exception $e) {
            echo "Adding column $col...\n";
            $pdo->exec("ALTER TABLE guests ADD COLUMN $col $def");
        }
    }

    echo "Database updated successfully.\n";

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