<?php
require 'config/db.php';

$missing = [];
$check = [
    'rto_name' => 'VARCHAR(255)',
    'rto_phone' => 'VARCHAR(20)',
    'rto_address' => 'TEXT',
    'invoice_no' => 'VARCHAR(100)',
    'invoice_value' => 'DECIMAL(10,2)',
    'ewaybill_no' => 'VARCHAR(100)'
];

foreach ($check as $col => $def) {
    try {
        $stmt = $pdo->query("SHOW COLUMNS FROM tbl_bookings LIKE '$col'");
        if (!$stmt->fetch()) {
            echo "Adding $col...\n";
            $pdo->exec("ALTER TABLE tbl_bookings ADD COLUMN $col $def");
        } else {
            echo "$col exists.\n";
        }
    } catch (PDOException $e) {
        echo "Error checking/adding $col: " . $e->getMessage() . "\n";
    }
}
?>