<?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::hasColumn('invite_codes', 'assigned_name')) {
            return;
        }

        Schema::table('invite_codes', function (Blueprint $table): void {
            $table->string('assigned_name', 50)->nullable()->after('role');
        });
    }

    public function down(): void
    {
        if (! Schema::hasColumn('invite_codes', 'assigned_name')) {
            return;
        }

        Schema::table('invite_codes', function (Blueprint $table): void {
            $table->dropColumn('assigned_name');
        });
    }
};
