<?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('user_subscriptions', function (Blueprint $table) {
            // Payment method: 'card', 'mobile_money', 'manual'
            $table->string('payment_method')->nullable()->after('status');
            // Amount captured at time of payment (keeps historical accuracy even if package price changes)
            $table->decimal('amount_usd', 10, 2)->nullable()->after('payment_method');
            $table->unsignedBigInteger('amount_ugx')->nullable()->after('amount_usd');
            // External transaction / reference ID from payment gateway
            $table->string('transaction_ref')->nullable()->after('amount_ugx');
        });
    }

    public function down(): void
    {
        Schema::table('user_subscriptions', function (Blueprint $table) {
            $table->dropColumn(['payment_method', 'amount_usd', 'amount_ugx', 'transaction_ref']);
        });
    }
};
