<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('ride_recommendations', function (Blueprint $table) {
            $table->id();
            $table->foreignId('ride_id')->constrained()->cascadeOnDelete();
            $table->foreignId('offer_id')->constrained()->cascadeOnDelete();
            $table->unsignedTinyInteger('position');
            $table->decimal('score', 8, 2)->nullable();
            $table->string('reason')->nullable();
            $table->boolean('was_viewed')->default(false);
            $table->boolean('was_clicked')->default(false);
            $table->timestamp('clicked_at')->nullable();
            $table->timestamps();

            $table->unique(['ride_id', 'offer_id']);
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('ride_recommendations');
    }
};
