<?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_data_sources', function (Blueprint $table) {
            $table->id();
            $table->foreignId('vehicle_record_id')->constrained()->cascadeOnDelete();
            $table->string('source_name');
            $table->string('source_url');
            $table->timestamp('last_fetched_at');
            $table->timestamp('cache_expires_at');
            $table->timestamps();

            $table->unique(['vehicle_record_id', 'source_name']);
        });
    }

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