<?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('ulasan', function (Blueprint $table) {
        $table->id();
        $table->foreignId('user_id')->constrained()->onDelete('cascade');
        $table->foreignId('pesanan_id')->constrained('pesanan')->onDelete('cascade');
        $table->foreignId('produk_id')->constrained('produk')->onDelete('cascade');
        $table->tinyInteger('bintang')->unsigned(); // 1-5
        $table->text('komentar')->nullable();
        $table->timestamps();

        // HAPUS BARIS INI ↓
        // $table->unique(['user_id', 'pesanan_id', 'produk_id']);
    });
}

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