<?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('immigopro_installment_payments', function (Blueprint $table) {
            $table->id();
            $table->foreignId('subscription_id')->constrained('immigo_pro_subscriptions')->onDelete('cascade');
            $table->integer('installment_number'); // 1, 2, 3, etc.
            $table->decimal('amount', 10, 2);
            $table->string('stripe_payment_intent_id')->nullable();
            $table->string('status')->default('completed'); // completed, failed
            $table->timestamp('paid_at')->nullable();
            $table->timestamps();
            
            $table->index('subscription_id');
        });
    }

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