From 494b8925db9aa442941b936ca1b9cfaefdb75f00 Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Thu, 31 Jul 2025 12:29:52 +0000 Subject: (김준회) MDG 수신 로직 개선건 오류 수정, 마이그레이션 대응 및 유틸 스크립트 경로 이동, DB connection 개수 제한 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/soap/batch-utils.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/soap/batch-utils.ts') diff --git a/lib/soap/batch-utils.ts b/lib/soap/batch-utils.ts index 785c85eb..76127fc2 100644 --- a/lib/soap/batch-utils.ts +++ b/lib/soap/batch-utils.ts @@ -71,10 +71,15 @@ export async function bulkReplaceSubTableData> parentIds: string[], chunkSize: number = 1000, ) { + // FK 값이 없는 서브테이블 건은 생략 if (!parentIds.length) return; - - // 1. 기존 데이터 일괄 삭제 - await tx.delete(table).where(inArray(parentField, parentIds)); + + // 마이그레이션시는 삭제 생략 + const skipDelete = process.env.SOAP_IGNORE_DELETE_FOR_MIGRATION === "true"; + + if (!skipDelete) { + await tx.delete(table).where(inArray(parentField, parentIds)); + } // 2. 새 데이터 일괄 삽입 (chunking) if (!data.length) return; -- cgit v1.2.3