<?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('appointments', function (Blueprint $table) {
            // Add missing columns for appointments
            $table->date('service_date')->nullable()->after('appointment_date');
            $table->time('service_time')->nullable()->after('appointment_time');
            $table->integer('duration')->default(60)->after('service_time'); // Duration in minutes
            $table->string('vehicle_registration', 20)->nullable()->after('car_year');
            
            // Add indexes for better performance
            $table->index(['service_date', 'service_time']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('appointments', function (Blueprint $table) {
            $table->dropColumn(['service_date', 'service_time', 'duration', 'vehicle_registration']);
        });
    }
};