diff --git a/LOGICAL_RELATIONSHIPS.md b/LOGICAL_RELATIONSHIPS.md index d6211e5..bafc746 100644 --- a/LOGICAL_RELATIONSHIPS.md +++ b/LOGICAL_RELATIONSHIPS.md @@ -1,6 +1,6 @@ # 논리적 데이터베이스 관계 문서 -> **자동 생성**: 2026-01-28 08:49:03 +> **자동 생성**: 2026-01-29 08:59:43 > **소스**: Eloquent 모델 관계 분석 ## 📊 모델별 관계 현황 diff --git a/database/migrations/2026_01_29_090000_fix_sales_scenario_checklists_unique_key.php b/database/migrations/2026_01_29_090000_fix_sales_scenario_checklists_unique_key.php new file mode 100644 index 0000000..fee45fd --- /dev/null +++ b/database/migrations/2026_01_29_090000_fix_sales_scenario_checklists_unique_key.php @@ -0,0 +1,48 @@ +dropUnique('sales_scenario_unique'); + + // checkpoint_index를 nullable로 변경 + $table->unsignedTinyInteger('checkpoint_index')->nullable()->change(); + + // 새 유니크 키 생성 (checkpoint_id 기반) + $table->unique( + ['tenant_id', 'scenario_type', 'step_id', 'checkpoint_id'], + 'sales_scenario_checkpoint_unique' + ); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('sales_scenario_checklists', function (Blueprint $table) { + // 새 유니크 키 삭제 + $table->dropUnique('sales_scenario_checkpoint_unique'); + + // checkpoint_index를 NOT NULL로 복원 + $table->unsignedTinyInteger('checkpoint_index')->nullable(false)->change(); + + // 기존 유니크 키 복원 + $table->unique( + ['tenant_id', 'user_id', 'step_id', 'checkpoint_index'], + 'sales_scenario_unique' + ); + }); + } +};