<?php

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

return new class extends Migration {
    /**
     * Run the migrations.
     * Agrega la columna departamento_destino_id a la tabla asignaciones
     * para permitir redirigir una solicitud a otro departamento.
     */
    public function up(): void
    {
        Schema::table('asignaciones', function (Blueprint $table) {
            $table->foreignId('departamento_destino_id')
                ->nullable()
                ->after('analista_id')
                ->constrained('departamentos')
                ->nullOnDelete();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('asignaciones', function (Blueprint $table) {
            $table->dropForeign(['departamento_destino_id']);
            $table->dropColumn('departamento_destino_id');
        });
    }
};
