<?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('requirement_operations', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained()->onDelete('cascade');
            $table->foreignId('r_id')->constrained('requirements')->onDelete('cascade');
            $table->foreignId('nfu_id')->constrained('non_functional_requirements')->onDelete('cascade');
            $table->foreignId('project_id')->constrained('projects')->onDelete('cascade');
            $table->double('nfu_value');
            $table->string('status')->default('done');
            $table->timestamps();

            // Add unique constraint if needed
            $table->unique(['user_id', 'r_id', 'nfu_id']);
        });
    }

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