<?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('expressions_of_interest', function (Blueprint $table) {
            $table->id();
            $table->string('code', 10)->unique();
            $table->foreignId('user_id')->constrained('users');
            $table->foreignId('opportunity_id')->constrained('investment_opportunities');
            $table->enum('status', ['nova', 'em_analise', 'aprovada', 'recusada'])->default('nova');
            $table->decimal('proposed_investment', 20, 2)->nullable();
            $table->text('message')->nullable();
            $table->text('admin_response')->nullable();
            $table->foreignId('responded_by')->nullable()->constrained('users');
            $table->timestamp('responded_at')->nullable();
            $table->timestamps();
            $table->softDeletes();
            $table->unique(['user_id', 'opportunity_id']);
            $table->index(['status', 'opportunity_id']);
            $table->index(['user_id', 'status']);
        });
    }

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