feat: [api-explorer] MNG API Explorer용 마이그레이션 추가

- admin_api_bookmarks: 즐겨찾기
- admin_api_templates: 요청 템플릿
- admin_api_histories: 요청 히스토리
- admin_api_environments: 환경 설정
This commit is contained in:
2025-12-17 22:06:35 +09:00
parent 17799c47de
commit 0eb9fb8501
4 changed files with 148 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?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');
}
};

View File

@@ -0,0 +1,39 @@
<?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_templates', 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('name', 100)->comment('템플릿 이름');
$table->text('description')->nullable()->comment('설명');
$table->json('headers')->nullable()->comment('요청 헤더');
$table->json('path_params')->nullable()->comment('경로 파라미터');
$table->json('query_params')->nullable()->comment('쿼리 파라미터');
$table->json('body')->nullable()->comment('요청 본문');
$table->boolean('is_shared')->default(false)->comment('공유 여부');
$table->timestamps();
$table->index(['user_id', 'endpoint', 'method']);
$table->index('is_shared');
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
});
}
public function down(): void
{
Schema::dropIfExists('admin_api_templates');
}
};

View File

@@ -0,0 +1,39 @@
<?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_histories', 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->json('request_headers')->nullable()->comment('요청 헤더');
$table->json('request_body')->nullable()->comment('요청 본문');
$table->integer('response_status')->comment('응답 상태 코드');
$table->json('response_headers')->nullable()->comment('응답 헤더');
$table->longText('response_body')->nullable()->comment('응답 본문');
$table->integer('duration_ms')->comment('응답 시간(ms)');
$table->string('environment', 50)->comment('실행 환경');
$table->timestamp('created_at')->nullable();
$table->index(['user_id', 'created_at']);
$table->index(['endpoint', 'method']);
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
});
}
public function down(): void
{
Schema::dropIfExists('admin_api_histories');
}
};

View File

@@ -0,0 +1,35 @@
<?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_environments', function (Blueprint $table) {
$table->id()->comment('ID');
$table->foreignId('user_id')->comment('사용자 ID');
$table->string('name', 50)->comment('환경 이름');
$table->string('base_url', 500)->comment('기본 URL');
$table->string('api_key', 500)->nullable()->comment('API 키 (암호화)');
$table->text('auth_token')->nullable()->comment('인증 토큰 (암호화)');
$table->json('variables')->nullable()->comment('환경 변수');
$table->boolean('is_default')->default(false)->comment('기본 환경 여부');
$table->timestamps();
$table->index('user_id');
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
});
}
public function down(): void
{
Schema::dropIfExists('admin_api_environments');
}
};