- MASTER_PLAN.md: 마이그레이션 전체 계획 - PROGRESS.md: 진행 상황 및 최종 결과 - phase-1: 5130 소스 스키마 분석 - phase-2: SAM 타겟 스키마 분석 - phase-3: 필드 매핑 설계 마이그레이션 결과: - 총 425건 품목 이관 완료 (models 18, parts 36, parts_sub 117, BDmodels 59, BOM 195) - tenant_id: 287 (경동기업) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
204 lines
5.8 KiB
Markdown
204 lines
5.8 KiB
Markdown
# 5130 → SAM 필드 매핑
|
|
|
|
> 작성일: 2025-12-21
|
|
> 대상: 경동기업 (tenant_id: 287)
|
|
|
|
---
|
|
|
|
## 1. 기본 설정
|
|
|
|
| 항목 | 값 |
|
|
|------|-----|
|
|
| tenant_id | 287 |
|
|
| 대상 회사 | 경동기업 |
|
|
| 제외 | 주일기업 (별도 테넌트로 추후 진행) |
|
|
|
|
---
|
|
|
|
## 2. 테이블 매핑
|
|
|
|
### 2.1 models → items (완제품)
|
|
|
|
| 5130 (models) | → | SAM (items) | 변환 규칙 |
|
|
|---------------|---|-------------|-----------|
|
|
| model_id | → | (item_id_mappings에 기록) | 매핑 추적용 |
|
|
| - | → | tenant_id | 고정값: 287 |
|
|
| - | → | item_type | 고정값: 'FG' |
|
|
| model_name | → | code | 그대로 (KSS01 등) |
|
|
| model_name | → | name | 그대로 |
|
|
| - | → | unit | 기본값: 'SET' |
|
|
| description | → | description | 그대로 |
|
|
| major_category | → | attributes.major_category | 스크린/스라트 |
|
|
| finishing_type | → | attributes.finishing_type | SUS마감/EGI마감 |
|
|
| guiderail_type | → | attributes.guiderail_type | 그대로 |
|
|
| is_deleted | → | deleted_at | 1이면 현재시간, 0이면 NULL |
|
|
| created_at | → | created_at | 그대로 |
|
|
| updated_at | → | updated_at | 그대로 |
|
|
|
|
**items.attributes JSON 구조:**
|
|
```json
|
|
{
|
|
"major_category": "스크린",
|
|
"finishing_type": "SUS마감",
|
|
"guiderail_type": "일반형",
|
|
"source": "5130",
|
|
"source_table": "models",
|
|
"source_id": 12
|
|
}
|
|
```
|
|
|
|
### 2.2 parts → items (부품)
|
|
|
|
| 5130 (parts) | → | SAM (items) | 변환 규칙 |
|
|
|--------------|---|-------------|-----------|
|
|
| part_id | → | (item_id_mappings에 기록) | 매핑 추적용 |
|
|
| - | → | tenant_id | 고정값: 287 |
|
|
| - | → | item_type | 고정값: 'PT' |
|
|
| part_name | → | code | 정규화 필요 (공백→언더스코어) |
|
|
| part_name | → | name | 그대로 |
|
|
| unit | → | unit | 그대로 (SET 등) |
|
|
| spec | → | attributes.spec | 규격 (120*70 등) |
|
|
| memo | → | description | 그대로 |
|
|
| unitprice | → | attributes.unit_price | varchar→decimal 변환 |
|
|
| img_url | → | attributes.image_url | 그대로 |
|
|
| is_deleted | → | deleted_at | 변환 |
|
|
| created_at | → | created_at | 그대로 |
|
|
| updated_at | → | updated_at | 그대로 |
|
|
|
|
**items.attributes JSON 구조:**
|
|
```json
|
|
{
|
|
"spec": "120*70",
|
|
"unit_price": 15000,
|
|
"image_url": "/img/parts/xxx.jpg",
|
|
"source": "5130",
|
|
"source_table": "parts",
|
|
"source_id": 49
|
|
}
|
|
```
|
|
|
|
### 2.3 parts_sub → items (원자재)
|
|
|
|
| 5130 (parts_sub) | → | SAM (items) | 변환 규칙 |
|
|
|------------------|---|-------------|-----------|
|
|
| subpart_id | → | (item_id_mappings에 기록) | 매핑 추적용 |
|
|
| - | → | tenant_id | 고정값: 287 |
|
|
| - | → | item_type | 고정값: 'RM' |
|
|
| subpart_name | → | code | 정규화 |
|
|
| subpart_name | → | name | 그대로 |
|
|
| - | → | unit | 기본값: 'EA' |
|
|
| material | → | attributes.material | SUS 1.2T 등 |
|
|
| bendSum | → | attributes.bend_sum | varchar→decimal |
|
|
| plateSum | → | attributes.plate_sum | varchar→decimal |
|
|
| finalSum | → | attributes.final_sum | varchar→decimal |
|
|
| unitPrice | → | attributes.unit_price | varchar→decimal |
|
|
| computedPrice | → | attributes.computed_price | varchar→decimal |
|
|
| lineTotal | → | attributes.line_total | varchar→decimal |
|
|
| image_url | → | attributes.image_url | 그대로 |
|
|
| is_deleted | → | deleted_at | 변환 |
|
|
| created_at | → | created_at | 그대로 |
|
|
| updated_at | → | updated_at | 그대로 |
|
|
|
|
**items.attributes JSON 구조:**
|
|
```json
|
|
{
|
|
"material": "SUS 1.2T",
|
|
"bend_sum": 5000,
|
|
"plate_sum": 3000,
|
|
"final_sum": 8000,
|
|
"unit_price": 1500,
|
|
"computed_price": 1500,
|
|
"line_total": 15000,
|
|
"image_url": "/img/sub/xxx.jpg",
|
|
"source": "5130",
|
|
"source_table": "parts_sub",
|
|
"source_id": 64
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## 3. 관계 매핑
|
|
|
|
### 3.1 models ↔ parts 관계
|
|
|
|
**entity_relationships 테이블 사용:**
|
|
|
|
| 필드 | 값 |
|
|
|------|-----|
|
|
| tenant_id | 287 |
|
|
| parent_type | 'items' |
|
|
| parent_id | (models에서 생성된 items.id) |
|
|
| child_type | 'items' |
|
|
| child_id | (parts에서 생성된 items.id) |
|
|
| order_no | parts.part_id 순서 |
|
|
| metadata | {"quantity": parts.quantity, "relation": "bom"} |
|
|
|
|
### 3.2 parts ↔ parts_sub 관계
|
|
|
|
**entity_relationships 테이블 사용:**
|
|
|
|
| 필드 | 값 |
|
|
|------|-----|
|
|
| tenant_id | 287 |
|
|
| parent_type | 'items' |
|
|
| parent_id | (parts에서 생성된 items.id) |
|
|
| child_type | 'items' |
|
|
| child_id | (parts_sub에서 생성된 items.id) |
|
|
| order_no | parts_sub.subpart_id 순서 |
|
|
| metadata | {"quantity": parts_sub.quantity, "relation": "bom"} |
|
|
|
|
---
|
|
|
|
## 4. ID 매핑 (item_id_mappings)
|
|
|
|
마이그레이션 추적을 위해 원본 ID 기록:
|
|
|
|
| source_table | source_id | item_id |
|
|
|--------------|-----------|---------|
|
|
| models | 12 | (생성된 ID) |
|
|
| parts | 49 | (생성된 ID) |
|
|
| parts_sub | 64 | (생성된 ID) |
|
|
|
|
---
|
|
|
|
## 5. 코드 생성 규칙
|
|
|
|
### 5.1 items.code 생성
|
|
|
|
| item_type | 코드 패턴 | 예시 |
|
|
|-----------|----------|------|
|
|
| FG (완제품) | 원본 model_name 유지 | KSS01, KSE01 |
|
|
| PT (부품) | PT-{정규화된 이름} | PT-UPPER_BRACKET |
|
|
| RM (원자재) | RM-{정규화된 이름} | RM-SUS_1_2T_FRONT |
|
|
|
|
### 5.2 정규화 규칙
|
|
- 한글 → 영문 변환 (또는 유지)
|
|
- 공백 → 언더스코어
|
|
- 특수문자 제거
|
|
- 대문자 변환
|
|
|
|
---
|
|
|
|
## 6. 타입 변환 규칙
|
|
|
|
| 원본 타입 | 대상 타입 | 변환 로직 |
|
|
|----------|----------|----------|
|
|
| varchar (가격) | decimal | 숫자만 추출, NULL이면 0 |
|
|
| tinyint (is_deleted) | timestamp (deleted_at) | 1→now(), 0→NULL |
|
|
| enum (major_category) | varchar (JSON) | 그대로 저장 |
|
|
| datetime | timestamp | 그대로 |
|
|
|
|
---
|
|
|
|
## 7. 마이그레이션 순서
|
|
|
|
1. **models → items** (FG) - 18건
|
|
2. **parts → items** (PT) - 37건
|
|
3. **parts_sub → items** (RM) - 134건
|
|
4. **models↔parts 관계 → entity_relationships**
|
|
5. **parts↔parts_sub 관계 → entity_relationships**
|
|
6. **item_id_mappings 기록**
|
|
|
|
**총 예상:** items 189건, entity_relationships 171건
|