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

            $table->foreignId('lesson_id')
                ->constrained()
                ->cascadeOnDelete()
                 ->unique();

            $table->string('title');

            $table->unsignedInteger('pass_mark')->default(60);

            $table->unsignedInteger('time_limit_minutes')->nullable();

            $table->boolean('shuffle_questions')->default(false);

            $table->timestamps();

            // One Lesson = One Quiz
            $table->unique('lesson_id');
        });
    }

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