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

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

            $table->unsignedInteger('year');
            $table->string('batch')->nullable(); 
            // e.g. March, August, Batch A, Batch B

            $table->string('title')->nullable();
            $table->text('description')->nullable();

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

            $table->timestamps();

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

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