<?php
/**
 * 1. lab_orders - إضافة أولوية الطلب (priority)
 */
$config = require __DIR__ . '/../config/config.php';
$pdo = new PDO(
    'mysql:host=' . $config['db']['host'] . ';dbname=' . $config['db']['name'] . ';charset=utf8mb4',
    $config['db']['user'],
    $config['db']['pass'],
    [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
);

$changes = [];

try {
    $pdo->query('SELECT priority FROM lab_orders LIMIT 1');
} catch (PDOException $e) {
    try {
        $pdo->exec("ALTER TABLE lab_orders ADD COLUMN priority ENUM('normal','urgent','high') NOT NULL DEFAULT 'normal' AFTER status");
        $changes[] = 'lab_orders.priority';
    } catch (PDOException $e2) {}
}

echo "Migration 020 done. Changes: " . implode(', ', $changes) . "\n";
