From 62d671edcff0e51d5a15fe858e151a48038cbf16 Mon Sep 17 00:00:00 2001 From: hskwon Date: Fri, 14 Nov 2025 11:29:22 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20stat=5Fsnapshots=20=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EB=B8=94=20=EC=A0=9C=EA=B1=B0=20(=ED=86=B5=EA=B3=84?= =?UTF-8?q?=20=EC=8B=9C=EC=8A=A4=ED=85=9C=EA=B3=BC=20=EB=B6=84=EB=A6=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [변경 이유] - 추후 별도 통계 시스템 구축 예정 - stat_snapshots는 캐싱용 스냅샷과 통계 시스템 역할이 겹침 - 역할 분리를 위해 제거 [변경 사항] - stat_snapshots 테이블 rollback 및 마이그레이션 파일 삭제 - tenant_stat_fields 테이블은 유지 (통계 시스템의 메타 정보로 활용) [유지되는 구조] - tenant_stat_fields: 각 테넌트가 통계를 원하는 필드 선언 - 통계 시스템 구축 시 이 메타 정보를 기반으로 통계 생성 [향후 계획] - 각 테넌트별 통계 데이터를 별도 통계 시스템에서 처리 - 리포트 기능에서 테넌트별 커스텀 통계 제공 --- LOGICAL_RELATIONSHIPS.md | 2 +- ..._14_000004_create_stat_snapshots_table.php | 97 ------------------- 2 files changed, 1 insertion(+), 98 deletions(-) delete mode 100644 database/migrations/2025_11_14_000004_create_stat_snapshots_table.php diff --git a/LOGICAL_RELATIONSHIPS.md b/LOGICAL_RELATIONSHIPS.md index 512c6df..f544ffa 100644 --- a/LOGICAL_RELATIONSHIPS.md +++ b/LOGICAL_RELATIONSHIPS.md @@ -1,6 +1,6 @@ # 논리적 데이터베이스 관계 문서 -> **자동 생성**: 2025-11-14 10:55:53 +> **자동 생성**: 2025-11-14 11:26:35 > **소스**: Eloquent 모델 관계 분석 ## 📊 모델별 관계 현황 diff --git a/database/migrations/2025_11_14_000004_create_stat_snapshots_table.php b/database/migrations/2025_11_14_000004_create_stat_snapshots_table.php deleted file mode 100644 index 4cabb88..0000000 --- a/database/migrations/2025_11_14_000004_create_stat_snapshots_table.php +++ /dev/null @@ -1,97 +0,0 @@ -id(); - $table->unsignedBigInteger('tenant_id')->comment('테넌트 ID'); - - // ================================================ - // 스냅샷 메타 정보 - // ================================================ - $table->string('snapshot_type', 50)->comment('스냅샷 타입 (daily, weekly, monthly)'); - $table->string('target_table', 50)->comment('통계 대상 테이블 (products, materials 등)'); - $table->date('snapshot_date')->comment('스냅샷 기준일'); - - // ================================================ - // 통계 대상 필드 - // ================================================ - $table->string('field_key', 100)->comment('통계 필드 키 (attributes JSON 내 키값)'); - $table->string('metric_type', 20)->comment('집계 함수 (avg, sum, min, max, count)'); - $table->decimal('metric_value', 18, 4)->nullable()->comment('계산된 통계 값'); - - // ================================================ - // 그룹화 기준 (선택적) - // ================================================ - $table->string('group_by_field', 100)->nullable()->comment('그룹화 기준 필드 (product_category, part_type 등)'); - $table->string('group_by_value', 100)->nullable()->comment('그룹화 기준 값 (SCREEN, STEEL 등)'); - - // ================================================ - // 신뢰성 정보 - // ================================================ - $table->integer('record_count')->nullable()->comment('계산에 사용된 레코드 수'); - $table->timestamp('calculated_at')->nullable()->comment('계산 실행 시각'); - - // ================================================ - // 감사 정보 - // ================================================ - $table->text('calculation_note')->nullable()->comment('계산 상세 정보 (에러 로그 등)'); - $table->timestamps(); - - // ================================================ - // 인덱스 - 조회 성능 최적화 - // ================================================ - $table->index(['tenant_id', 'snapshot_type', 'snapshot_date'], 'idx_stat_snapshots_tenant_type_date'); - $table->index(['tenant_id', 'target_table', 'field_key', 'snapshot_date'], 'idx_stat_snapshots_field_lookup'); - $table->index(['tenant_id', 'target_table', 'group_by_field', 'group_by_value'], 'idx_stat_snapshots_group_lookup'); - $table->index(['snapshot_date', 'calculated_at'], 'idx_stat_snapshots_freshness'); - - // ================================================ - // 유니크 제약 (중복 스냅샷 방지) - // ================================================ - $table->unique( - ['tenant_id', 'snapshot_type', 'snapshot_date', 'target_table', 'field_key', 'metric_type', 'group_by_field', 'group_by_value'], - 'idx_stat_snapshots_unique' - ); - - // ================================================ - // 외래 키 (개발 환경에서만 권장) - // ================================================ - // $table->foreign('tenant_id')->references('id')->on('tenants')->onDelete('cascade'); - }); - } - - public function down(): void - { - Schema::dropIfExists('stat_snapshots'); - } -};