<?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::table('ocr_question_results', function (Blueprint $table) {
            $table->unsignedBigInteger('question_bank_id')->nullable()->after('ocr_record_id')->comment('题库题目ID');
            $table->string('generation_status')->default('pending')->after('question_bank_id')->comment('题库生成状态: pending, generating, completed, failed');
            $table->string('generation_task_id')->nullable()->after('generation_status')->comment('异步生成任务ID');
            $table->text('generation_error')->nullable()->after('generation_task_id')->comment('生成失败错误信息');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('ocr_question_results', function (Blueprint $table) {
            $table->dropColumn([
                'question_bank_id',
                'generation_status',
                'generation_task_id',
                'generation_error'
            ]);
        });
    }
};
