<?php
require_once __DIR__ . '/app/Config.php';
require_once __DIR__ . '/app/Database.php';

\Peak\Config::init();
try {
    $pdo = \Peak\Database::get();
    $pdo->exec("ALTER TABLE users ADD COLUMN tokens INT NOT NULL DEFAULT 50");
    $pdo->exec("ALTER TABLE users ADD COLUMN tokens_last_reset DATETIME DEFAULT CURRENT_TIMESTAMP");
    $pdo->exec("ALTER TABLE users ADD COLUMN unlimited_tokens TINYINT(1) DEFAULT 0");
    echo "Columns added successfully!\n";
} catch (\Exception $e) {
    if (strpos($e->getMessage(), 'Duplicate column name') !== false) {
        echo "Columns already exist.\n";
    } else {
        echo "Error: " . $e->getMessage() . "\n";
    }
}
