<?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('payment_providers', function (Blueprint $table) {
            $table->id();
            $table->string('name', 50)->unique();
            $table->string('display_name');
            $table->text('description')->nullable();
            $table->boolean('is_active')->default(true);
            $table->json('configuration');
            $table->boolean('supports_recurring')->default(false);
            $table->boolean('supports_one_time')->default(true);
            $table->json('supported_currencies')->default('[]');
            $table->string('webhook_url')->nullable();
            $table->string('webhook_secret')->nullable();
            $table->json('fee_structure')->nullable();
            $table->integer('priority')->default(0);
            $table->boolean('is_fallback')->default(false);
            $table->timestamps();

            // Indexes
            $table->index('is_active');
            $table->index('priority');
            $table->index('is_fallback');
        });
    }

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