<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('vehicle_inspections', function (Blueprint $table) {
            // Only add columns that don't exist
            if (!Schema::hasColumn('vehicle_inspections', 'signature_inspector')) {
                $table->text('signature_inspector')->nullable()->after('inspection_date');
            }
            if (!Schema::hasColumn('vehicle_inspections', 'signature_customer')) {
                $table->text('signature_customer')->nullable()->after('signature_inspector');
            }
            if (!Schema::hasColumn('vehicle_inspections', 'notes')) {
                $table->text('notes')->nullable()->after('signature_customer');
            }
            if (!Schema::hasColumn('vehicle_inspections', 'follow_up_required')) {
                $table->boolean('follow_up_required')->default(false)->after('notes');
            }
            if (!Schema::hasColumn('vehicle_inspections', 'quality_rating')) {
                $table->integer('quality_rating')->nullable()->after('follow_up_required');
            }
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('vehicle_inspections', function (Blueprint $table) {
            $table->dropColumn([
                'signature_inspector',
                'signature_customer',
                'notes',
                'follow_up_required',
                'quality_rating',
            ]);
        });
    }
};
