<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('tickets', function (Blueprint $table) {
            $table->string('moved_to_type')->nullable()->after('stage_id');
            $table->unsignedBigInteger('moved_to_id')->nullable()->after('moved_to_type');
            $table->timestamp('moved_at')->nullable()->after('moved_to_id');
        });

        Schema::table('leads', function (Blueprint $table) {
            $table->string('moved_to_type')->nullable()->after('status');
            $table->unsignedBigInteger('moved_to_id')->nullable()->after('moved_to_type');
            $table->timestamp('moved_at')->nullable()->after('moved_to_id');
        });
    }

    public function down(): void
    {
        Schema::table('tickets', fn (Blueprint $table) => $table->dropColumn([
            'moved_to_type', 'moved_to_id', 'moved_at',
        ]));
        Schema::table('leads', fn (Blueprint $table) => $table->dropColumn([
            'moved_to_type', 'moved_to_id', 'moved_at',
        ]));
    }
};
