<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('form_questions', function (Blueprint $table) {
            $table->id();
            $table->foreignId('form_id')->constrained('evaluation_forms')->onDelete('cascade');
            $table->text('question_text');
            $table->enum('question_type', ['likert_1_5', 'likert_1_4', 'text', 'multiple_choice'])->index();
            $table->json('options')->nullable();
            $table->integer('order')->default(0);
            $table->boolean('is_required')->default(true);
            $table->timestamps();
            
            $table->index(['form_id', 'order']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('form_questions');
    }
};
