<?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('divisions', function (Blueprint $table) {
            $table->foreignId('leader_id')->nullable()->constrained('users')->nullOnDelete()->after('description');
        });
    }

    public function down(): void
    {
        Schema::table('divisions', function (Blueprint $table) {
            $table->dropForeignIdFor(\App\Models\User::class, 'leader_id');
            $table->dropColumn('leader_id');
        });
    }
};
