ALTER TABLE vehicle_fuel_entries
    ADD COLUMN IF NOT EXISTS voucher_id VARCHAR(40) NULL AFTER id,
    ADD COLUMN IF NOT EXISTS created_by_user_id BIGINT NULL AFTER voucher_id,
    ADD COLUMN IF NOT EXISTS approved_by_user_id BIGINT NULL AFTER created_by_user_id,
    ADD COLUMN IF NOT EXISTS approval_status ENUM('Pending','Approved','Rejected') NOT NULL DEFAULT 'Pending' AFTER approved_by_user_id,
    ADD COLUMN IF NOT EXISTS fueling_time TIME NULL AFTER record_date,
    ADD COLUMN IF NOT EXISTS fueling_type VARCHAR(50) NULL AFTER fueling_time,
    ADD COLUMN IF NOT EXISTS fueling_status VARCHAR(50) NULL AFTER fueling_type,
    ADD COLUMN IF NOT EXISTS office_id BIGINT UNSIGNED NULL AFTER vehicle_id,
    ADD COLUMN IF NOT EXISTS office_name VARCHAR(120) NULL AFTER office_id,
    ADD COLUMN IF NOT EXISTS company_name VARCHAR(150) NULL AFTER office_name,
    ADD COLUMN IF NOT EXISTS fleet_supervisor_user_id BIGINT NULL AFTER driver_id,
    ADD COLUMN IF NOT EXISTS fleet_supervisor_name VARCHAR(120) NULL AFTER fleet_supervisor_user_id,
    ADD COLUMN IF NOT EXISTS fuel_level VARCHAR(30) NULL AFTER fuel_type_id,
    ADD COLUMN IF NOT EXISTS quantity_litres DECIMAL(12,2) NULL AFTER fuel_level,
    ADD COLUMN IF NOT EXISTS dispensed_litres DECIMAL(12,2) NULL AFTER quantity_litres,
    ADD COLUMN IF NOT EXISTS filling_station VARCHAR(150) NULL AFTER dispensed_litres,
    ADD COLUMN IF NOT EXISTS actual_mileage INT NULL AFTER filling_station,
    ADD COLUMN IF NOT EXISTS mileage_km INT NULL AFTER actual_mileage,
    ADD COLUMN IF NOT EXISTS mileage_date DATE NULL AFTER mileage_km,
    ADD COLUMN IF NOT EXISTS mileage_time TIME NULL AFTER mileage_date,
    ADD COLUMN IF NOT EXISTS card_balance DECIMAL(14,2) NULL AFTER total_amount,
    ADD COLUMN IF NOT EXISTS comment_text TEXT NULL AFTER notes;

ALTER TABLE vehicle_fuel_entries
    ADD UNIQUE KEY IF NOT EXISTS uq_vehicle_fuel_entries_voucher_id (voucher_id),
    ADD KEY IF NOT EXISTS idx_vehicle_fuel_entries_approval_status (approval_status),
    ADD KEY IF NOT EXISTS idx_vehicle_fuel_entries_office (office_id),
    ADD KEY IF NOT EXISTS idx_vehicle_fuel_entries_created_by (created_by_user_id),
    ADD KEY IF NOT EXISTS idx_vehicle_fuel_entries_approved_by (approved_by_user_id);
