<?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('interview_categories', function (Blueprint $table) {
            $table->unsignedBigInteger('parent_id')->nullable()->after('interview_project_id')->comment('부모 카테고리 ID (대분류→중분류)');
            $table->index('parent_id', 'idx_interview_categories_parent');
            $table->foreign('parent_id')->references('id')->on('interview_categories')->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('interview_categories', function (Blueprint $table) {
            $table->dropForeign(['parent_id']);
            $table->dropIndex('idx_interview_categories_parent');
            $table->dropColumn('parent_id');
        });
    }
};
