<?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
    {
        if (Schema::hasTable('student_exercises')) {
            Schema::table('student_exercises', function (Blueprint $table) {
                // 修改difficulty_level字段为DECIMAL(3,2)以匹配题库
                $table->decimal('difficulty_level', 3, 2)->comment('题目难度值')->change();
            });
        }
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        if (Schema::hasTable('student_exercises')) {
            Schema::table('student_exercises', function (Blueprint $table) {
                // 回滚到整数类型（如果需要）
                $table->integer('difficulty_level')->comment('题目难度值')->change();
            });
        }
    }
};
