<?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('quizzes', function (Blueprint $table) {
            if (! Schema::hasColumn('quizzes', 'test_type')) {
                $table->string('test_type')->default('General')->after('slug');
            }

            if (! Schema::hasColumn('quizzes', 'is_enabled')) {
                $table->boolean('is_enabled')->default(true)->after('status');
            }
        });
    }

    public function down(): void
    {
        Schema::table('quizzes', function (Blueprint $table) {
            if (Schema::hasColumn('quizzes', 'is_enabled')) {
                $table->dropColumn('is_enabled');
            }

            if (Schema::hasColumn('quizzes', 'test_type')) {
                $table->dropColumn('test_type');
            }
        });
    }
};
