<?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_bookmarks', function (Blueprint $table) {
            $table->id()->comment('ID');
            $table->foreignId('user_id')->comment('사용자 ID');
            $table->string('endpoint', 500)->comment('API 엔드포인트');
            $table->string('method', 10)->comment('HTTP 메서드');
            $table->string('display_name', 100)->nullable()->comment('표시 이름');
            $table->integer('display_order')->default(0)->comment('표시 순서');
            $table->string('color', 20)->nullable()->comment('색상');
            $table->timestamps();

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

            $table->foreign('user_id')
                ->references('id')
                ->on('users')
                ->onDelete('cascade');
        });
    }

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