<?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('broadcast_history', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->comment('Admin user ID');
            $table->integer('sender_role_id')->default(0)->comment('In-game role ID of sender');
            $table->integer('channel')->comment('Chat channel ID');
            $table->string('channel_name', 50)->comment('Chat channel name');
            $table->text('message')->comment('Broadcast message');
            $table->enum('status', ['sent', 'failed'])->default('sent')->comment('Broadcast status');
            $table->timestamps();

            $table->index('user_id');
            $table->index('created_at');
        });
    }

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