docs: [data-sync] 마스터 데이터 동기화 계획 추가 + 전체 동기화 문서 업데이트
- master-data-sync-plan.md 신규: 31개 마스터 테이블, 양방향(local↔dev↔prod) - local-to-dev-data-sync-plan.md 업데이트: 35→62개 테이블 확장, FK 의존성 전수 분석 - kd_price_tables 삭제 반영 (미사용 레거시)
This commit is contained in:
@@ -59,59 +59,89 @@
|
||||
|
||||
---
|
||||
|
||||
## 2. 대상 테이블 (35개)
|
||||
## 2. 대상 테이블 (62개 + 참조 users)
|
||||
|
||||
### 2.1 데이터 현황 (tenant_id=287, 2026-03-10 기준)
|
||||
### 2.1 데이터 현황 (tenant_id=287, 2026-03-17 기준)
|
||||
|
||||
| # | 카테고리 | 테이블 | 건수 | tenant_id | 비고 |
|
||||
|---|---------|--------|------|-----------|------|
|
||||
| | **품목기준** | | | | |
|
||||
| 1 | 품목 | items | 893 | ✅ direct | |
|
||||
| 2 | 카테고리 | categories | 72 | ✅ direct | |
|
||||
| | **공정관리** | | | | |
|
||||
| 3 | 공정 | processes | 4 | ✅ direct | |
|
||||
| 4 | 공정단계 | process_steps | 19 | ❌ FK | process_id → processes |
|
||||
| 5 | 분류규칙 | process_classification_rules | 0 | ❌ FK | process_id → processes |
|
||||
| | **견적** | | | | |
|
||||
| 6 | 견적 | quotes | 49 | ✅ direct | |
|
||||
| 7 | 견적품목 | quote_items | 2,018 | ✅ direct | |
|
||||
| 8 | 견적수정 | quote_revisions | 75 | ✅ direct | |
|
||||
| | **수주** | | | | |
|
||||
| 9 | 수주 | orders | 41 | ✅ direct | |
|
||||
| 10 | 수주품목 | order_items | 2,475 | ✅ direct | |
|
||||
| 11 | 수주노드 | order_nodes | 143 | ✅ direct | 자체참조 (parent_id) |
|
||||
| | **생산/작업지시** | | | | |
|
||||
| 12 | 작업지시 | work_orders | 120 | ✅ direct | |
|
||||
| 13 | 작업품목 | work_order_items | 545 | ❌ FK | work_order_id → work_orders |
|
||||
| 14 | 단계진행 | work_order_step_progress | 1,092 | ✅ direct | |
|
||||
| 15 | 담당자 | work_order_assignees | 9 | ✅ direct | |
|
||||
| 16 | 원자재투입 | work_order_material_inputs | 72 | ✅ direct | |
|
||||
| 17 | 이슈 | work_order_issues | 1 | ❌ FK | work_order_id → work_orders |
|
||||
| 18 | 벤딩상세 | work_order_bending_details | 0 | ❌ FK | work_order_id → work_orders |
|
||||
| | **출하** | | | | |
|
||||
| 19 | 출하 | shipments | 8 | ✅ direct | |
|
||||
| 20 | 출하품목 | shipment_items | 14 | ❌ FK | shipment_id → shipments |
|
||||
| 21 | 배차 | shipment_vehicle_dispatches | 2 | ✅ direct | |
|
||||
| | **재고** | | | | |
|
||||
| 22 | 재고현황 | stocks | 8,611 | ✅ direct | |
|
||||
| 23 | LOT | stock_lots | 191 | ✅ direct | |
|
||||
| 24 | 입고 | receivings | 60 | ✅ direct | |
|
||||
| 25 | 거래이력 | stock_transactions | 420 | ✅ direct | |
|
||||
| | **품질** | | | | |
|
||||
| 26 | 검사 | inspections | 0 | ✅ direct | IQC/PQC/FQC |
|
||||
| 27 | 품질관리서 | quality_documents | 2 | ✅ direct | |
|
||||
| 28 | 품질-수주연결 | quality_document_orders | 1 | ❌ FK | quality_document_id |
|
||||
| 29 | 품질-현장 | quality_document_locations | 4 | ❌ FK | quality_document_id |
|
||||
| 30 | 성능리포트 | performance_reports | 1 | ❌ FK | quality_document_id |
|
||||
| | **넘버링** | | | | |
|
||||
| 31 | 넘버링규칙 | numbering_rules | 2 | ✅ direct | |
|
||||
| 32 | 넘버링시퀀스 | numbering_sequences | 14 | ✅ direct | 독립 테이블 (FK 없음) |
|
||||
| | **파일** | | | | |
|
||||
| 33 | 파일 | files | 51 | ✅ direct | |
|
||||
| 34 | 폴더 | folders | 5 | ✅ direct | |
|
||||
| | **매출** | | | | |
|
||||
| 35 | 매출 | sales | 81 | ✅ direct | |
|
||||
| | **합계** | **35개** | **~17,840** | | |
|
||||
| # | 카테고리 | 테이블 | tenant_id | 비고 |
|
||||
|---|---------|--------|-----------|------|
|
||||
| | **기준 정보** | | | |
|
||||
| 1 | 품목 | items | ✅ direct | |
|
||||
| 2 | 카테고리 | categories | ✅ direct | |
|
||||
| 3 | 부서 | departments | ✅ direct | work_orders.team_id 참조 |
|
||||
| 4 | 거래처 | clients | ✅ direct | quotes/orders/shipments 참조 |
|
||||
| 5 | 거래처그룹 | client_groups | ✅ direct | clients.client_group_id 참조 |
|
||||
| 6 | 공통코드 | common_codes | ✅ direct | |
|
||||
| 7 | 계정코드 | account_codes | ✅ direct | |
|
||||
| 8 | 카테고리그룹 | category_groups | ✅ direct | |
|
||||
| | **품목 하위** | | | |
|
||||
| 9 | 품목필드 | item_fields | ✅ direct | |
|
||||
| 10 | 품목섹션 | item_sections | ✅ direct | |
|
||||
| 11 | 품목페이지 | item_pages | ✅ direct | |
|
||||
| 12 | BOM구성 | item_bom_items | ✅ direct | |
|
||||
| 13 | 단가 | prices | ✅ direct | 견적 단가 조회 필수 |
|
||||
| 14 | 엔티티관계 | entity_relationships | ✅ direct | |
|
||||
| | **공정관리** | | | |
|
||||
| 15 | 공정 | processes | ✅ direct | |
|
||||
| 16 | 공정단계 | process_steps | ❌ FK | process_id → processes |
|
||||
| 17 | 분류규칙 | process_classification_rules | ❌ FK | process_id → processes |
|
||||
| | **견적** | | | |
|
||||
| 18 | 견적 | quotes | ✅ direct | |
|
||||
| 19 | 견적품목 | quote_items | ✅ direct | |
|
||||
| 20 | 견적수정 | quote_revisions | ✅ direct | |
|
||||
| | **수주** | | | |
|
||||
| 21 | 수주 | orders | ✅ direct | |
|
||||
| 22 | 수주품목 | order_items | ✅ direct | |
|
||||
| 23 | 수주노드 | order_nodes | ✅ direct | 자체참조 (parent_id) |
|
||||
| 24 | 수주이력 | order_histories | ✅ direct | |
|
||||
| 25 | 수주품목구성 | order_item_components | ✅ direct | |
|
||||
| | **생산/작업지시** | | | |
|
||||
| 26 | 작업지시 | work_orders | ✅ direct | |
|
||||
| 27 | 작업품목 | work_order_items | ❌ FK | work_order_id → work_orders |
|
||||
| 28 | 단계진행 | work_order_step_progress | ✅ direct | |
|
||||
| 29 | 담당자 | work_order_assignees | ✅ direct | |
|
||||
| 30 | 원자재투입 | work_order_material_inputs | ✅ direct | |
|
||||
| 31 | 이슈 | work_order_issues | ❌ FK | work_order_id → work_orders |
|
||||
| 32 | 벤딩상세 | work_order_bending_details | ❌ FK | work_order_id → work_orders |
|
||||
| 33 | 작업실적 | work_results | ✅ direct | |
|
||||
| 34 | 작업설정 | work_settings | ✅ direct | |
|
||||
| | **출하** | | | |
|
||||
| 35 | 출하 | shipments | ✅ direct | |
|
||||
| 36 | 출하품목 | shipment_items | ❌ FK | shipment_id → shipments |
|
||||
| 37 | 배차 | shipment_vehicle_dispatches | ✅ direct | |
|
||||
| | **재고** | | | |
|
||||
| 38 | 재고현황 | stocks | ✅ direct | |
|
||||
| 39 | LOT | stock_lots | ✅ direct | |
|
||||
| 40 | 입고 | receivings | ✅ direct | |
|
||||
| 41 | 거래이력 | stock_transactions | ✅ direct | |
|
||||
| | **품질** | | | |
|
||||
| 42 | 검사 | inspections | ✅ direct | IQC/PQC/FQC |
|
||||
| 43 | 품질관리서 | quality_documents | ✅ direct | |
|
||||
| 44 | 품질-수주연결 | quality_document_orders | ❌ FK | quality_document_id |
|
||||
| 45 | 품질-현장 | quality_document_locations | ❌ FK | quality_document_id |
|
||||
| 46 | 성능리포트 | performance_reports | ❌ FK | quality_document_id |
|
||||
| 47 | 심사체크리스트 | audit_checklists | ✅ direct | |
|
||||
| 48 | 심사카테고리 | audit_checklist_categories | ✅ direct | |
|
||||
| 49 | 심사항목 | audit_checklist_items | ✅ direct | |
|
||||
| 50 | 심사표준문서 | audit_standard_documents | ✅ direct | |
|
||||
| 51 | 체크리스트템플릿 | checklist_templates | ✅ direct | |
|
||||
| | **넘버링** | | | |
|
||||
| 52 | 넘버링규칙 | numbering_rules | ✅ direct | |
|
||||
| 53 | 넘버링시퀀스 | numbering_sequences | ✅ direct | |
|
||||
| | **파일** | | | |
|
||||
| 54 | 파일 | files | ✅ direct | |
|
||||
| 55 | 폴더 | folders | ✅ direct | |
|
||||
| | **문서** | | | |
|
||||
| 56 | 문서 | documents | ✅ direct | |
|
||||
| 57 | 문서템플릿 | document_templates | ✅ direct | |
|
||||
| 58 | 문서데이터 | document_data | ✅ direct | |
|
||||
| 59 | 문서승인 | document_approvals | ✅ direct | |
|
||||
| 60 | 문서첨부 | document_attachments | ✅ direct | |
|
||||
| | **매출** | | | |
|
||||
| 61 | 매출 | sales | ✅ direct | |
|
||||
| | **참조 (REPLACE INTO)** | | | |
|
||||
| 62 | 사용자 | users | ❌ 참조 | user_tenants 기준, DELETE 안 함 |
|
||||
| | **합계** | **62개** | | direct 52 + FK 9 + 참조 1 |
|
||||
|
||||
### 2.2 파일 저장소
|
||||
|
||||
@@ -123,16 +153,23 @@
|
||||
| 총 크기 | 8.9MB |
|
||||
| 하위 구조 | `items/`, `temp/`, `logo_*.jpeg` |
|
||||
|
||||
### 2.3 제외 대상
|
||||
### 2.3 참조 users 동기화
|
||||
|
||||
- `user_tenants`에서 `tenant_id=287`인 user_id를 수집
|
||||
- 해당 users만 `REPLACE INTO`로 동기화 (DELETE 안 함 — 다른 테넌트 영향 방지)
|
||||
- 대상: 거의 모든 테이블의 `created_by`, `updated_by`, `assignee_id`, `inspector_id` 등
|
||||
|
||||
### 2.4 제외 대상
|
||||
|
||||
| 테이블 | 제외 사유 |
|
||||
|--------|----------|
|
||||
| users, tenants, departments | 계정/조직 별도 관리 |
|
||||
| clients | 거래처 별도 관리 (필요시 추가) |
|
||||
| tenants | 환경별 독립 관리 |
|
||||
| user_tenants, tenant_user_profiles | 개발서버에서 별도 설정 |
|
||||
| audit_logs | 감사 로그는 환경별 독립 |
|
||||
| file_share_links, file_deletion_logs | 환경별 독립 |
|
||||
| storage_usage_history | 모니터링 환경별 독립 |
|
||||
| schedules, equipments 등 | 현재 데이터 0건 (향후 데이터 생기면 추가) |
|
||||
| kd_price_tables | 삭제됨 (EstimatePriceService가 items+prices로 대체) |
|
||||
|
||||
---
|
||||
|
||||
@@ -243,7 +280,7 @@ ssh hskwon@114.203.209.83 \
|
||||
|
||||
### 4.1 SoftDeletes 처리
|
||||
|
||||
대상 35개 중 **19개+ 테이블에 SoftDeletes 적용** (Item, Order, WorkOrder, Quote 등).
|
||||
대상 62개 중 **다수 테이블에 SoftDeletes 적용** (Item, Order, WorkOrder, Quote 등).
|
||||
|
||||
- **dump**: `--where="tenant_id=287"`은 soft deleted 포함 → **올바름** (상태 보존)
|
||||
- **DELETE**: SQL DELETE는 deleted_at과 무관하게 모두 삭제 → **올바름**
|
||||
@@ -255,6 +292,7 @@ ssh hskwon@114.203.209.83 \
|
||||
- **tenant_id 필터**: 모든 DELETE에 `WHERE tenant_id = 287` → 다른 테넌트 보호
|
||||
- **complete-insert**: ID 값 포함 dump → auto_increment 충돌 방지
|
||||
- **order_nodes 자체참조**: FK_CHECKS=0이므로 삽입 순서 무관
|
||||
- **users REPLACE INTO**: DELETE 안 함 → 다른 테넌트의 사용자 데이터 보호
|
||||
|
||||
### 4.3 반복 실행 시 주의
|
||||
|
||||
@@ -279,4 +317,5 @@ ssh hskwon@114.203.209.83 \
|
||||
| 날짜 | 작업 | 비고 |
|
||||
|------|------|------|
|
||||
| 2026-03-10 | 최초 작성 | 대상 35개 테이블, 47개 파일 |
|
||||
| 2026-03-10 | 단순화 | Artisan+웹UI → 셸 스크립트 1개. IP 수정 (211.117.60.189→114.203.209.83). numbering_sequences FK 오류 수정. SoftDeletes 처리 명시. 제외 테이블 보완 |
|
||||
| 2026-03-10 | 단순화 | Artisan+웹UI → 셸 스크립트 1개. IP 수정 (211.117.60.189→114.203.209.83). numbering_sequences FK 오류 수정. SoftDeletes 처리 명시. 제외 테이블 보완 |
|
||||
| 2026-03-17 | 대폭 확장 | 35개→62개 테이블. 소스 코드 belongsTo 기준 FK 의존성 전수 분석. departments, clients, client_groups, prices, item_*, order_histories, audit_*, common_codes, account_codes 등 21개 추가. users 참조 동기화 (REPLACE INTO). kd_price_tables 삭제 (미사용 레거시) |
|
||||
Reference in New Issue
Block a user