diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/soap/batch-utils.ts | 11 | ||||
| -rw-r--r-- | lib/soap/mdg/send/vendor-master/action.ts | 2 |
2 files changed, 9 insertions, 4 deletions
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<T extends Record<string, unknown>> 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; diff --git a/lib/soap/mdg/send/vendor-master/action.ts b/lib/soap/mdg/send/vendor-master/action.ts index 88b46508..d35d7a76 100644 --- a/lib/soap/mdg/send/vendor-master/action.ts +++ b/lib/soap/mdg/send/vendor-master/action.ts @@ -17,7 +17,7 @@ import { VENDOR_MASTER_BP_HEADER_BP_VENGEN_BP_PORG_ZVPFN } from "@/db/schema/MDG/mdg"; import { eq, sql, desc } from "drizzle-orm"; -import { withSoapLogging } from "../../utils"; +import { withSoapLogging } from "../../../utils"; import { XMLBuilder } from 'fast-xml-parser'; import { CSV_FIELDS } from './csv-fields'; |
