<?php

require_once __DIR__ . '/../vendor/autoload.php';

use App\Config\Database;

try {
    $conn = Database::getInstance()->getConnection();

    echo "Adicionando coluna machine_id na tabela servers...\n";

    // Check if column exists
    $stmt = $conn->prepare("SHOW COLUMNS FROM servers LIKE 'machine_id'");
    $stmt->execute();
    if ($stmt->fetch()) {
        echo "Coluna machine_id já existe.\n";
    } else {
        $conn->exec("ALTER TABLE servers ADD COLUMN machine_id VARCHAR(255) DEFAULT NULL AFTER serial_key");
        echo "Coluna machine_id adicionada com sucesso.\n";
    }

} catch (Exception $e) {
    echo "Erro: " . $e->getMessage() . "\n";
    exit(1);
}
