<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

// PRC-794 — Escalation kuralına "şu admin'e ata" action'ı (assign_to_agent).
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('escalation_rules', function (Blueprint $table) {
            $table->unsignedBigInteger('action_assign_to_admin_id')->nullable()->after('action_flag_to_admin_id');
            $table->foreign('action_assign_to_admin_id')->references('id')->on('admins')->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('escalation_rules', function (Blueprint $table) {
            $table->dropForeign(['action_assign_to_admin_id']);
            $table->dropColumn('action_assign_to_admin_id');
        });
    }
};
