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

            $table->foreignId('demo_exam_id')
                ->constrained('demo_exams')
                ->cascadeOnDelete();

            $table->foreignId('course_id')
                ->constrained()
                ->cascadeOnDelete();

            $table->longText('question');
            $table->text('explanation')->nullable();

            $table->unsignedInteger('sort_order')->default(0);
            $table->boolean('is_active')->default(true);

            $table->timestamps();

            $table->index(['demo_exam_id', 'course_id']);
        });
    }

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