d74263eaed
PART 상세 다이얼로그 검증 중 발견: 품번/품명만 표시되고 재료/규격/계정구분/조달구분/ 재고단위/관리단위/환산수량/LOT구분/사용여부/검사여부/SET품여부/의뢰여부 등 거의 모든 컬럼이 NULL. 운영DB 같은 part_no 는 정상 채움 — 마이그레이션 누락. 01_part_mng_sync.sql: - 운영DB(11133/waceplm) → /tmp/part_mng_sync.csv export - TEMP staging 테이블 → RPS DB(11134/vexplor_rps) part_mng UPDATE FROM JOIN - 동기화 컬럼 20개: material / heat_treatment_(hardness/method) / surface_treatment / maker / part_type / spec / acctfg / odrfg / unit_dc / unitmang_dc / unitchng_nb / lot_fg / use_yn / qc_fg / setitem_fg / req_fg / unit_length / unit_qty / is_last - is_last 도 같이 COALESCE(p.is_last, '1') 로 채움 — 마이그레이션 시 NULL 이라 partMng 매퍼의 IS_LAST='1' 조건이 0건 반환되던 부수 문제 동시 해결 결과 (2026-05-12 실행): 8,176건 UPDATE. · material 301 / acctfg 8,172 / unit_dc 8,176 / spec 7,466 / part_type 703 / is_last 8,176 미동기화: 운영DB 에만 있는 67건 (운영 8,243 - RPS 8,176). part_no 자체가 RPS 에 미존재 → 신규 INSERT 별 작업. 대상 데이터: - 본 디렉토리는 *.sql .gitignore 우회 git add -f 로 강제 트래킹 (영업/프로젝트관리 ddl-extracted 패턴 동일) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3.2 KiB
3.2 KiB
개발관리 데이터 동기화 스크립트
운영DB(211.115.91.141:11133/waceplm) → RPS DB(11134/vexplor_rps)로 마이그레이션 시 누락된 데이터를 part_no 매칭으로 채워 넣는 1회성 스크립트 모음.
테이블 DDL/스키마는 ../ddl-extracted/에서 별도 관리. 본 디렉토리는 데이터 row 동기화 전용.
01_part_mng_sync.sql
대상: part_mng 8,176건 — 운영DB에서 채워져 있던 컬럼이 RPS 마이그레이션 시 누락된 사례.
왜 필요했나: 2026-05-12 PART 상세 다이얼로그 검증 중 발견. 품번/품명만 표시되고 재료/규격/계정구분/조달구분/재고단위/관리단위/환산수량/LOT구분/사용여부/검사여부/SET품여부/의뢰여부 등 거의 모든 컬럼이 NULL. 운영DB 같은 part_no는 정상적으로 채워져 있어서 마이그레이션 누락이 원인.
동기화 대상 컬럼 20개:
- 재료/형상:
material/heat_treatment_hardness/heat_treatment_method/surface_treatment - 기본:
maker/part_type/spec - ERP 분류:
acctfg/odrfg/unit_dc/unitmang_dc/unitchng_nb - Y/N:
lot_fg/use_yn/qc_fg/setitem_fg/req_fg - 단위:
unit_length/unit_qty - 상태:
is_last(마이그레이션 시 NULL이라 PART_MNG.is_last='1' 조건의 모든 매퍼 쿼리가 0건 반환되던 부수 문제도 함께 수정)
실행 절차:
# 1) 운영DB → CSV export (is_last='1' 인 8,243건)
PGPASSWORD='waceplm0909!!' psql -h 211.115.91.141 -p 11133 -U postgres -d waceplm -c "\copy (SELECT part_no, COALESCE(material,''), COALESCE(heat_treatment_hardness,''), ..., COALESCE(unit_qty::text,'') FROM part_mng WHERE is_last='1') TO '/tmp/part_mng_sync.csv' WITH CSV HEADER"
# 2) RPS 에 import + UPDATE FROM JOIN
PGPASSWORD='vexplor0909!!' psql -h 211.115.91.141 -p 11134 -U postgres -d vexplor_rps -f 01_part_mng_sync.sql
결과 (2026-05-12 실행):
| 컬럼 | 동기화 전 | 동기화 후 |
|---|---|---|
| material | 0 | 301 |
| acctfg | 0 | 8,172 |
| unit_dc | 0 | 8,176 |
| part_type | 639 | 703 |
| spec | 0 | 7,466 |
| is_last | 0 | 8,176 |
| (전체) | 8,176 | 8,176 |
미동기화 (의도적 보류): 운영DB에만 있는 67건 (운영 8,243 - RPS 8,176). part_no 자체가 RPS 에 미존재. 신규 INSERT 별 작업 필요.
검증 SQL:
-- 채움 비율
SELECT
COUNT(*) AS total,
COUNT(NULLIF(material,'')) AS material_filled,
COUNT(NULLIF(acctfg,'')) AS acctfg_filled,
COUNT(NULLIF(unit_dc,'')) AS unit_dc_filled,
COUNT(NULLIF(part_type,'')) AS part_type_filled,
COUNT(NULLIF(spec,'')) AS spec_filled,
COUNT(NULLIF(is_last,'')) AS is_last_filled
FROM part_mng;
-- 샘플 행 (운영 스크린샷과 비교)
SELECT part_no, material, spec, part_type, acctfg, odrfg, unit_dc, unitmang_dc,
unitchng_nb, lot_fg, use_yn, qc_fg, setitem_fg, req_fg
FROM part_mng WHERE part_no = '000AN003000';
1:1 정합성: 운영DB의 컬럼 값을 그대로 복사. NULL 인 운영 컬럼은 RPS 도 NULL 유지 (덮어쓰기 안 함). unitchng_nb 만 numeric 캐스팅.
재실행 안전: idempotent — 같은 데이터로 다시 UPDATE 만 일어남.