<?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::create('vehicle_documents', function (Blueprint $table) {
            $table->id();
            $table->foreignId('car_id')->constrained()->onDelete('cascade');
            $table->date('registration_expiry_date');
            $table->date('inspection_date');
            $table->date('inspection_expiry_date');
            $table->string('registration_document')->nullable();
            $table->string('inspection_document')->nullable();
            $table->enum('status', ['valid', 'expiring_soon', 'expired'])->default('valid');
            $table->text('notes')->nullable();
            $table->foreignId('created_by')->constrained('users');
            $table->timestamps();

            $table->index('car_id');
            $table->index('inspection_expiry_date');
            $table->index('registration_expiry_date');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('vehicle_documents');
    }
};
