<?php
/**
 * Patch: adiciona colunas map_lat e map_lng à tabela nms_devices
 * Execute uma vez: php patch_map_coords.php
 */
require_once __DIR__ . '/db.php';
require_once __DIR__ . '/config.php';

$pdo = db();

$sqls = [
    "ALTER TABLE nms_devices ADD COLUMN IF NOT EXISTS map_lat  DECIMAL(10,7) NULL",
    "ALTER TABLE nms_devices ADD COLUMN IF NOT EXISTS map_lng  DECIMAL(10,7) NULL",
];

foreach ($sqls as $sql) {
    try {
        $pdo->exec($sql);
        echo "OK: $sql\n";
    } catch (PDOException $e) {
        echo "SKIP: " . $e->getMessage() . "\n";
    }
}

echo "Patch map_coords concluído!\n";
