32 lines
993 B
PHP
Executable File
32 lines
993 B
PHP
Executable File
<?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('test_id')->constrained()->onDelete('cascade');
|
|
$table->enum('type', ['single_choice', 'multiple_choice', 'matching', 'ordering'])->default('multiple_choice');
|
|
$table->text('question_text');
|
|
$table->text('explanation')->nullable();
|
|
$table->integer('score')->default(1);
|
|
$table->integer('sort_order')->default(0);
|
|
$table->boolean('is_required')->default(true);
|
|
$table->timestamps();
|
|
|
|
$table->index('test_id');
|
|
$table->index('type');
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('questions');
|
|
}
|
|
};
|