<?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('admin_api_deprecations', function (Blueprint $table) {
            $table->id();
            $table->string('endpoint', 500)->comment('API 엔드포인트');
            $table->string('method', 10)->comment('HTTP 메서드');
            $table->enum('status', ['candidate', 'scheduled', 'deprecated', 'removed'])
                ->default('candidate')
                ->comment('상태: 후보, 예정, 폐기됨, 삭제됨');
            $table->text('reason')->nullable()->comment('폐기 사유');
            $table->date('scheduled_date')->nullable()->comment('폐기 예정일');
            $table->date('deprecated_date')->nullable()->comment('실제 폐기일');
            $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
            $table->timestamps();

            $table->unique(['endpoint', 'method']);
            $table->index('status');
        });
    }

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