<?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
    {
        // Add question_weights to exams table
        Schema::table('exams', function (Blueprint $table) {
            $table->json('question_weights')->nullable()->after('show_answer');
        });

        // Add manual_score and is_graded to answers table
        Schema::table('answers', function (Blueprint $table) {
            $table->decimal('manual_score', 5, 2)->nullable()->after('is_correct');
            $table->enum('is_graded', ['Y', 'N'])->default('N')->after('manual_score');
        });
    }

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

        Schema::table('answers', function (Blueprint $table) {
            $table->dropColumn(['manual_score', 'is_graded']);
        });
    }
};
