<?php

use App\Enums\QuestionExplanationTypeEnum;
use App\Enums\QuestionTypeEnum;
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::create('questions', function (Blueprint $table) {
            $table->id();
            $table->foreignIdFor(\App\Models\QuestionCategory::class)->constrained('question_categories')->cascadeOnDelete();
            $table->enum('explanation_type', QuestionExplanationTypeEnum::values())->default(QuestionExplanationTypeEnum::TEXT);
            $table->integer('time_limit')->default(0);
            $table->integer('order')->default(1);
            $table->enum('question_type', QuestionTypeEnum::values())->default(QuestionTypeEnum::MULTIPLE_CHOICE);
            $table->longText('options')->nullable();
            $table->longText('correct_answers')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('questions');
    }
};
