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

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

            $table->longText('question');

            $table->string('difficulty')->default('medium'); 
            // easy, medium, hard

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

            $table->boolean('is_premium')->default(false);
            $table->boolean('is_active')->default(true);

            $table->timestamps();

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

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