<?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('sponsors', function (Blueprint $table) {
            if (!Schema::hasColumn('sponsors', 'api_token')) {
                $table->string('api_token', 100)->nullable()->unique()->after('status');
            }
            if (!Schema::hasColumn('sponsors', 'license_file')) {
                $table->string('license_file')->nullable()->after('api_token');
            }
            if (!Schema::hasColumn('sponsors', 'organization_name')) {
                $table->string('organization_name')->nullable()->after('full_name');
            }
        });
    }

    public function down(): void
    {
        Schema::table('sponsors', function (Blueprint $table) {
            $table->dropColumn(['api_token', 'license_file', 'organization_name']);
        });
    }
};
