<?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::table('care_payments', function (Blueprint $table) {
            $table->string('status', 20)->default('paid')->after('method'); // pending|paid|failed
            $table->string('gateway_provider', 32)->nullable()->after('status');
            $table->index(['reference']);
            $table->index(['bill_id', 'status']);
        });
    }

    public function down(): void
    {
        Schema::table('care_payments', function (Blueprint $table) {
            $table->dropIndex(['care_payments_reference_index']);
            $table->dropIndex(['care_payments_bill_id_status_index']);
            $table->dropColumn(['status', 'gateway_provider']);
        });
    }
};
