<?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_records', function (Blueprint $table) {
            // 添加试卷形式字段
            $table->string('paper_type', 32)->nullable()->after('qr_code_data')->comment('试卷形式：unit_test-单元测试, midterm-期中考试, final-期末考试, homework-家庭作业, quiz-随堂测验, other-其他');

            // 添加索引
            $table->index('paper_type', 'idx_ocr_records_paper_type');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('ocr_records', function (Blueprint $table) {
            $table->dropIndex('idx_ocr_records_paper_type');
            $table->dropColumn('paper_type');
        });
    }
};
