<?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('interview_categories', function (Blueprint $table) {
            if (!Schema::hasColumn('interview_categories', 'icon')) {
                $table->string('icon')->nullable()->after('description');
            }
            if (!Schema::hasColumn('interview_categories', 'color')) {
                $table->string('color')->nullable()->after('icon');
            }
            if (!Schema::hasColumn('interview_categories', 'question_count')) {
                $table->unsignedInteger('question_count')->default(0)->after('color');
            }
            if (!Schema::hasColumn('interview_categories', 'time_limit')) {
                $table->unsignedInteger('time_limit')->default(30)->comment('minutes')->after('question_count');
            }
            if (!Schema::hasColumn('interview_categories', 'deleted_at')) {
                $table->softDeletes();
            }
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('interview_categories', function (Blueprint $table) {
            $table->dropColumnIfExists(['icon', 'color', 'question_count', 'time_limit', 'deleted_at']);
        });
    }
};
