<?php

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

/**
 * failed_step 컬럼 타입 변경
 *
 * 원인: FlowExecutor가 stepId (문자열, 예: 'login')를 반환하는데,
 *       컬럼이 smallint로 정의되어 있어서 저장 실패
 *
 * 변경: smallint → varchar(100)
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('admin_api_flow_runs', function (Blueprint $table) {
            $table->string('failed_step', 100)->nullable()->change();
        });
    }

    public function down(): void
    {
        Schema::table('admin_api_flow_runs', function (Blueprint $table) {
            $table->smallInteger('failed_step')->nullable()->change();
        });
    }
};
