<?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::create('exam_student_rel', function (Blueprint $table) {
      $table->id();

      $table->unsignedBigInteger('exam_id');
      $table
        ->foreign('exam_id')
        ->references('id')
        ->on('exams')
        ->onDelete('cascade');

      $table->unsignedBigInteger('student_id');
      $table
        ->foreign('student_id')
        ->references('id')
        ->on('students')
        ->onDelete('cascade');

      $table->timestamps();
    });
  }

  /**
   * Reverse the migrations.
   */
  public function down(): void
  {
    Schema::dropIfExists('exam_student_rel');
  }
};
