feat: 트리거 감사로그 operation_id 컬럼 추가 및 요청별 UUID 설정
- trigger_audit_logs 테이블에 operation_id(VARCHAR 36) 컬럼 추가 - ix_trig_operation 인덱스 생성 (일괄 롤백 조회용) - SetAuditSessionVariables 미들웨어에서 요청마다 @sam_operation_id UUID 설정 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# 논리적 데이터베이스 관계 문서
|
||||
|
||||
> **자동 생성**: 2026-02-13 11:19:58
|
||||
> **자동 생성**: 2026-02-12 20:26:02
|
||||
> **소스**: Eloquent 모델 관계 분석
|
||||
|
||||
## 📊 모델별 관계 현황
|
||||
|
||||
@@ -5,12 +5,16 @@
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class SetAuditSessionVariables
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
// 요청 단위 operation_id (인증 여부와 무관하게 항상 설정)
|
||||
DB::statement('SET @sam_operation_id = ?', [Str::uuid()->toString()]);
|
||||
|
||||
if (auth()->check()) {
|
||||
DB::statement('SET @sam_actor_id = ?', [auth()->id()]);
|
||||
DB::statement('SET @sam_session_info = ?', [
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// 파티셔닝된 테이블에 컬럼 추가
|
||||
DB::statement("
|
||||
ALTER TABLE trigger_audit_logs
|
||||
ADD COLUMN operation_id VARCHAR(36) DEFAULT NULL COMMENT '작업 단위 ID (요청별 UUID)' AFTER session_info
|
||||
");
|
||||
|
||||
// operation_id 인덱스 (일괄 롤백 조회용)
|
||||
DB::statement("
|
||||
CREATE INDEX ix_trig_operation
|
||||
ON trigger_audit_logs (operation_id, created_at)
|
||||
");
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
DB::statement('DROP INDEX ix_trig_operation ON trigger_audit_logs');
|
||||
DB::statement('ALTER TABLE trigger_audit_logs DROP COLUMN operation_id');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user