<?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::create('tenant_bootstrap_runs', function (Blueprint $t) {
            $t->bigIncrements('id');
            $t->unsignedBigInteger('tenant_id');
            $t->string('recipe', 50)->default('STANDARD');
            $t->string('status', 20)->default('PENDING'); // PENDING|RUNNING|SUCCESS|FAILED
            $t->json('steps')->nullable();   // 실행된 스텝 목록
            $t->json('log')->nullable();     // 메시지/에러 요약
            $t->unsignedSmallInteger('recipe_version')->default(1);
            $t->timestamps();

            $t->index(['tenant_id', 'recipe']);
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('tenant_bootstrap_runs');
    }
};
