<?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('tailor_ratings', function (Blueprint $table) {
            $table->id();
            $table->foreignId('booking_id')->constrained()->onDelete('cascade');
            $table->foreignId('customer_id')->constrained('users')->onDelete('cascade');
            $table->foreignId('tailor_id')->constrained('users')->onDelete('cascade');
            $table->decimal('rating', 2, 1); // Rating 0.0 - 5.0
            $table->text('review')->nullable();
            $table->timestamps();

            // Satu customer hanya bisa memberikan satu rating per booking
            $table->unique(['booking_id', 'customer_id']);
        });
    }

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