<?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::table('transactions', function (Blueprint $table) {
            // Entity risk breakdown (sender)
            $table->jsonb('entity_risk_breakdown')->nullable()->after('counterparty_kyc_risk_level');

            // Counterparty risk breakdown (receiver)
            $table->jsonb('counterparty_risk_breakdown')->nullable()->after('entity_risk_breakdown');

            // Transaction plausibility breakdown
            $table->jsonb('transaction_plausibility_breakdown')->nullable()->after('counterparty_risk_breakdown');

            // Combined risk breakdown
            $table->jsonb('combined_risk_breakdown')->nullable()->after('transaction_plausibility_breakdown');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('transactions', function (Blueprint $table) {
            $table->dropColumn([
                'entity_risk_breakdown',
                'counterparty_risk_breakdown',
                'transaction_plausibility_breakdown',
                'combined_risk_breakdown',
            ]);
        });
    }
};
