<?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('customers', function (Blueprint $table): void {
            $table->timestamp('bvn_verified_at')->nullable()->after('bvn');
            $table->timestamp('nin_verified_at')->nullable()->after('nin');
            $table->timestamp('kyc_locked_at')->nullable()->after('kyc_verified_at');
            $table->string('kyc_provider')->nullable()->after('kyc_verification_method');
            $table->string('kyc_provider_session_id')->nullable()->after('kyc_provider');
            $table->string('kyc_provider_status')->nullable()->after('kyc_provider_session_id');
            $table->text('kyc_provider_url')->nullable()->after('kyc_provider_status');
            $table->json('kyc_provider_response')->nullable()->after('kyc_provider_url');

            $table->index(['tenant_id', 'kyc_provider_status']);
        });
    }

    public function down(): void
    {
        Schema::table('customers', function (Blueprint $table): void {
            $table->dropIndex(['tenant_id', 'kyc_provider_status']);
            $table->dropColumn([
                'bvn_verified_at',
                'nin_verified_at',
                'kyc_locked_at',
                'kyc_provider',
                'kyc_provider_session_id',
                'kyc_provider_status',
                'kyc_provider_url',
                'kyc_provider_response',
            ]);
        });
    }
};
