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

      $table->unsignedBigInteger('admin_id');
      $table
        ->foreign('admin_id')
        ->references('id')
        ->on('admins')
        ->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_admin_rel');
  }
};
