<?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('papers', function (Blueprint $table) {
            $table->integer('diagnostic_chapter_id')->nullable()->after('paper_type')->comment('摸底的章节ID');
            $table->index('diagnostic_chapter_id', 'idx_papers_diagnostic_chapter_id');
        });
    }

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