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

            $table->foreignId('call_queue_id')->constrained()->cascadeOnDelete();
            $table->foreignId('agent_id')->constrained('users')->cascadeOnDelete();

            $table->unsignedInteger('priority')->default(100);
            $table->boolean('is_active')->default(true)->index();

            $table->timestamps();

            $table->unique(['call_queue_id', 'agent_id']);
        });
    }

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