<?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('payout_schedules', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->foreignUuid('investment_id')->nullable()->constrained()->nullOnDelete();
            $table->date('scheduled_date');
            $table->decimal('amount', 15, 2);
            $table->string('status')->default('pending'); // pending, paid, cancelled
            $table->string('type')->default('dividend'); // dividend, refund
            $table->string('notes')->nullable();
            $table->timestamp('processed_at')->nullable();
            $table->timestamps();

            $table->index(['scheduled_date', 'status']);
        });
    }

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