<?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
    {
        if (!Schema::hasTable('users') || Schema::hasColumn('users', 'ban_reason')) {
            return;
        }

        Schema::table('users', function (Blueprint $table) {
            $table->text('ban_reason')->nullable()->after('is_banned');
        });
    }

    public function down(): void
    {
        if (!Schema::hasTable('users') || !Schema::hasColumn('users', 'ban_reason')) {
            return;
        }

        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('ban_reason');
        });
    }
};
