<?php
require_once 'config/database.php';
try {
    // Add missing columns to vehicle_assignments table
    $pdo->exec('ALTER TABLE vehicle_assignments ADD COLUMN assignment_start DATE NOT NULL AFTER driver_id');
    $pdo->exec('ALTER TABLE vehicle_assignments ADD COLUMN assignment_end DATE NULL AFTER assignment_start');
    $pdo->exec('ALTER TABLE vehicle_assignments MODIFY COLUMN status ENUM("active","inactive","suspended") NOT NULL DEFAULT "active"');
    $pdo->exec('ALTER TABLE vehicle_assignments ADD COLUMN notes TEXT NULL AFTER leased_days');
    $pdo->exec('ALTER TABLE vehicle_assignments ADD COLUMN created_by_user_id BIGINT UNSIGNED NULL AFTER notes');
    $pdo->exec('ALTER TABLE vehicle_assignments ADD COLUMN updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER created_at');
    $pdo->exec('ALTER TABLE vehicle_assignments ADD COLUMN company_id BIGINT UNSIGNED NULL AFTER driver_id');
    echo 'Table updated successfully';
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage();
}
?>