<?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('api_request_logs', function (Blueprint $table) {
            $table->string('group_id', 50)->nullable()->after('tenant_id')->comment('요청 그룹 ID (연관 API 묶음)');
            $table->index('group_id');
            $table->index(['tenant_id', 'user_id', 'created_at']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('api_request_logs', function (Blueprint $table) {
            $table->dropIndex(['group_id']);
            $table->dropIndex(['tenant_id', 'user_id', 'created_at']);
            $table->dropColumn('group_id');
        });
    }
};
