<?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('partner_investments', function (Blueprint $table) {
            $table->id();
            $table->foreignId('partner_id')->constrained('users')->cascadeOnDelete();
            $table->foreignId('investment_property_id')->constrained('investment_properties')->cascadeOnDelete();
            $table->integer('shares_purchased');
            $table->decimal('total_investment', 12, 2);
            $table->timestamp('purchase_date')->useCurrent();
            $table->enum('status', ['active', 'sold', 'transferred'])->default('active');
            $table->timestamps();

            $table->index('partner_id');
            $table->index('investment_property_id');
        });
    }

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