<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

/**
 * Per-link display price override. Lets a single plan show different
 * amounts/currencies per provider — necessary when an admin enables both
 * Stripe (USD) and Razorpay (INR) for the same plan, since the plan's
 * own `monthly_price_cents` + `currency` only reflects ONE of those.
 *
 * Both columns nullable. When null, the /pricing page falls back to
 * `plans.monthly_price_cents` / `plans.currency`. When set, both must be
 * set together — admin form enforces that.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('plan_provider_links', function (Blueprint $table) {
            $table->unsignedInteger('display_amount_minor')->nullable()->after('provider_price_id');
            $table->string('display_currency', 3)->nullable()->after('display_amount_minor');
        });
    }

    public function down(): void
    {
        Schema::table('plan_provider_links', function (Blueprint $table) {
            $table->dropColumn(['display_amount_minor', 'display_currency']);
        });
    }
};
