<?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('users', function (Blueprint $table): void {
            $table->boolean('wallet_frozen')->default(false)->index()->after('status');
            $table->foreignId('merged_into_user_id')->nullable()->constrained('users')->nullOnDelete()->after('wallet_frozen');
            $table->timestamp('merged_at')->nullable()->after('merged_into_user_id');
            $table->timestamp('closed_at')->nullable()->after('merged_at');
        });
    }

    public function down(): void
    {
        Schema::table('users', function (Blueprint $table): void {
            $table->dropForeign(['merged_into_user_id']);
            $table->dropColumn(['wallet_frozen', 'merged_into_user_id', 'merged_at', 'closed_at']);
        });
    }
};
