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

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

      $table->unsignedBigInteger('notice_id');
      $table
        ->foreign('notice_id')
        ->references('id')
        ->on('notices')
        ->onDelete('cascade');

      $table->string('status')->default('unread');

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

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