<?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('trip_ratings', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('booking_id');
            $table->integer('passenger_rating')->nullable();
            $table->integer('driver_rating')->nullable();
            $table->text('passenger_feedback')->nullable();
            $table->text('driver_feedback')->nullable();
            $table->timestamp('passenger_rated_at')->nullable();
            $table->timestamp('driver_rated_at')->nullable();
            $table->timestamps();
            
            $table->foreign('booking_id')->references('id')->on('bookings')->onDelete('cascade');
            $table->unique('booking_id');
        });
    }

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