<?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::create('demo_exam_options', function (Blueprint $table) {
            $table->id();

            $table->foreignId('demo_exam_question_id')
                ->constrained('demo_exam_questions')
                ->cascadeOnDelete();

            $table->string('option_key', 5);
            $table->longText('option_text');
            $table->boolean('is_correct')->default(false);

            $table->timestamps();

            $table->unique(['demo_exam_question_id', 'option_key']);
            $table->index(['demo_exam_question_id', 'is_correct']);
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('demo_exam_options');
    }
};