<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->unsignedBigInteger('user_category_id')->nullable()->after('user_category');
            $table->unsignedBigInteger('user_type_id')->nullable()->after('user_type');
            
            $table->foreign('user_category_id')->references('id')->on('user_categories')->onDelete('set null');
            $table->foreign('user_type_id')->references('id')->on('user_types')->onDelete('set null');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropForeign(['user_category_id']);
            $table->dropForeign(['user_type_id']);
            $table->dropColumn(['user_category_id', 'user_type_id']);
        });
    }
};
