<?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('activity_logs', function (Blueprint $table) {
            $table->string('action_label', 32)->nullable()->after('method');
            $table->string('target_type', 64)->nullable()->after('path');
            $table->unsignedBigInteger('target_id')->nullable()->after('target_type');
            $table->foreignId('target_user_id')->nullable()->after('target_id')->constrained('users')->nullOnDelete();
            $table->string('target_user_name', 120)->nullable()->after('target_user_id');
            $table->string('description', 255)->nullable()->after('target_user_name');
        });
    }

    public function down(): void
    {
        Schema::table('activity_logs', function (Blueprint $table) {
            $table->dropConstrainedForeignId('target_user_id');
            $table->dropColumn([
                'action_label',
                'target_type',
                'target_id',
                'target_user_name',
                'description',
            ]);
        });
    }
};
