From eeb55d1c282a0ab60bda0eb0f4760aa93b04ecda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Mon, 26 Jan 2026 22:12:17 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=AC=B8=EC=84=9C=20=ED=85=9C=ED=94=8C?= =?UTF-8?q?=EB=A6=BF=20=EB=A7=88=EC=9D=B4=EA=B7=B8=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=85=98=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EA=B4=80=EA=B3=84?= =?UTF-8?q?=20=EB=AC=B8=EC=84=9C=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - document_templates 테이블 마이그레이션 추가 - LOGICAL_RELATIONSHIPS.md 업데이트 Co-Authored-By: Claude Opus 4.5 --- LOGICAL_RELATIONSHIPS.md | 2 +- ...200000_create_document_templates_table.php | 117 ++++++++++++++++++ 2 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2026_01_26_200000_create_document_templates_table.php diff --git a/LOGICAL_RELATIONSHIPS.md b/LOGICAL_RELATIONSHIPS.md index aa05c5d..575494d 100644 --- a/LOGICAL_RELATIONSHIPS.md +++ b/LOGICAL_RELATIONSHIPS.md @@ -1,6 +1,6 @@ # 논리적 데이터베이스 관계 문서 -> **자동 생성**: 2026-01-26 16:11:41 +> **자동 생성**: 2026-01-26 22:07:37 > **소스**: Eloquent 모델 관계 분석 ## 📊 모델별 관계 현황 diff --git a/database/migrations/2026_01_26_200000_create_document_templates_table.php b/database/migrations/2026_01_26_200000_create_document_templates_table.php new file mode 100644 index 0000000..d239e03 --- /dev/null +++ b/database/migrations/2026_01_26_200000_create_document_templates_table.php @@ -0,0 +1,117 @@ +id(); + $table->foreignId('tenant_id')->constrained()->cascadeOnDelete(); + $table->string('name', 100)->comment('양식명'); + $table->string('category', 50)->nullable()->comment('분류 (품질, 생산 등)'); + $table->string('title', 200)->nullable()->comment('문서 제목'); + $table->string('company_name', 100)->nullable()->comment('회사명'); + $table->string('company_address', 255)->nullable()->comment('회사 주소'); + $table->string('company_contact', 100)->nullable()->comment('회사 연락처'); + $table->string('footer_remark_label', 50)->default('부적합 내용')->comment('비고 라벨'); + $table->string('footer_judgement_label', 50)->default('종합판정')->comment('판정 라벨'); + $table->json('footer_judgement_options')->nullable()->comment('판정 옵션 (적합/부적합 등)'); + $table->boolean('is_active')->default(true)->comment('활성 여부'); + $table->timestamps(); + $table->softDeletes(); + + $table->index(['tenant_id', 'category']); + $table->index(['tenant_id', 'is_active']); + }); + + // 결재라인 + Schema::create('document_template_approval_lines', function (Blueprint $table) { + $table->id(); + $table->foreignId('template_id')->constrained('document_templates')->cascadeOnDelete(); + $table->string('name', 50)->comment('결재 단계명 (작성, 검토, 승인)'); + $table->string('dept', 50)->nullable()->comment('부서'); + $table->string('role', 50)->nullable()->comment('직책/담당자'); + $table->unsignedSmallInteger('sort_order')->default(0); + $table->timestamps(); + + $table->index(['template_id', 'sort_order']); + }); + + // 기본 필드 (품명, LOT NO 등) + Schema::create('document_template_basic_fields', function (Blueprint $table) { + $table->id(); + $table->foreignId('template_id')->constrained('document_templates')->cascadeOnDelete(); + $table->string('label', 50)->comment('필드 라벨'); + $table->string('field_type', 20)->default('text')->comment('필드 타입 (text, date 등)'); + $table->string('default_value', 255)->nullable()->comment('기본값'); + $table->unsignedSmallInteger('sort_order')->default(0); + $table->timestamps(); + + $table->index(['template_id', 'sort_order']); + }); + + // 검사 기준서 섹션 + Schema::create('document_template_sections', function (Blueprint $table) { + $table->id(); + $table->foreignId('template_id')->constrained('document_templates')->cascadeOnDelete(); + $table->string('title', 100)->comment('섹션 제목 (가이드레일, 연기차단재 등)'); + $table->string('image_path', 255)->nullable()->comment('도해 이미지 경로'); + $table->unsignedSmallInteger('sort_order')->default(0); + $table->timestamps(); + + $table->index(['template_id', 'sort_order']); + }); + + // 검사 기준서 섹션 항목 + Schema::create('document_template_section_items', function (Blueprint $table) { + $table->id(); + $table->foreignId('section_id')->constrained('document_template_sections')->cascadeOnDelete(); + $table->string('category', 50)->nullable()->comment('구분 (겉모양, 치수 등)'); + $table->string('item', 100)->comment('검사항목'); + $table->string('standard', 255)->nullable()->comment('검사기준'); + $table->string('method', 50)->nullable()->comment('검사방법'); + $table->string('frequency', 50)->nullable()->comment('검사주기'); + $table->string('regulation', 100)->nullable()->comment('관련규정'); + $table->unsignedSmallInteger('sort_order')->default(0); + $table->timestamps(); + + $table->index(['section_id', 'sort_order']); + }); + + // 검사 데이터 테이블 컬럼 설정 + Schema::create('document_template_columns', function (Blueprint $table) { + $table->id(); + $table->foreignId('template_id')->constrained('document_templates')->cascadeOnDelete(); + $table->string('label', 50)->comment('컬럼명'); + $table->string('width', 20)->default('100px')->comment('컬럼 너비'); + $table->string('column_type', 20)->default('text')->comment('타입 (text, check, measurement, select, complex)'); + $table->string('group_name', 50)->nullable()->comment('그룹명 (상단 헤더 병합용)'); + $table->json('sub_labels')->nullable()->comment('서브라벨 배열'); + $table->unsignedSmallInteger('sort_order')->default(0); + $table->timestamps(); + + $table->index(['template_id', 'sort_order']); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('document_template_columns'); + Schema::dropIfExists('document_template_section_items'); + Schema::dropIfExists('document_template_sections'); + Schema::dropIfExists('document_template_basic_fields'); + Schema::dropIfExists('document_template_approval_lines'); + Schema::dropIfExists('document_templates'); + } +}; \ No newline at end of file