HoshiAI-be/database/migrations/2025_11_11_154002_create_questions_table.php

39 lines
1.1 KiB
PHP

<?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('questions', function (Blueprint $table) {
$table->id();
$table->string('title', 255);
$table->text('description')->nullable();
$table->enum('type', ['single', 'multiple', 'text']);
$table->integer('difficulty');
$table->unsignedBigInteger('category_id')->nullable();
$table->unsignedBigInteger('author_id')->nullable();
$table->text('variants');
$table->json('correct_answers');
$table->foreign('author_id')->references('id')->on('users')->onDelete('set null');
$table->foreign('category_id')->references('id')->on('categories')->onDelete('set null');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('questions');
}
};