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'); - } -};