<?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::table('system_assistant_logs', function (Blueprint $table) {
            $table->string('session_id')->nullable()->index()->after('user_id');
            $table->string('tool')->nullable()->after('request_type');
            $table->string('intent')->nullable()->after('tool');
            $table->string('status')->default('success')->after('execution_time_ms');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('system_assistant_logs', function (Blueprint $table) {
            $table->dropIndex(['session_id']);
            $table->dropColumn(['session_id', 'tool', 'intent', 'status']);
        });
    }
};
