<?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('answers', function (Blueprint $table) {
            $table->index(['exam_id', 'student_id', 'exam_session_id'], 'answers_exam_student_session_index');
        });

        Schema::table('grades', function (Blueprint $table) {
            $table->index(['exam_id', 'student_id'], 'grades_exam_student_index');
            $table->index(['exam_id', 'student_id', 'exam_session_id'], 'grades_exam_student_session_index');
        });
    }

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

        Schema::table('grades', function (Blueprint $table) {
            $table->dropIndex('grades_exam_student_index');
            $table->dropIndex('grades_exam_student_session_index');
        });
    }
};
