From b753727394e4314e08a1cd3a73f2a71ea9693975 Mon Sep 17 00:00:00 2001 From: hyungi Date: Sat, 27 Jun 2026 06:54:54 +0900 Subject: [PATCH] =?UTF-8?q?fix(migration):=20validator=20=EA=B0=80=20?= =?UTF-8?q?=EC=9D=B8=EB=9D=BC=EC=9D=B8=20=EC=A3=BC=EC=84=9D=EC=9D=98=20com?= =?UTF-8?q?mit/begin=20=EB=8B=A8=EC=96=B4=20false-positive=20=E2=80=94=20f?= =?UTF-8?q?resh=20DB=20=EB=B6=80=ED=8A=B8=EC=8A=A4=ED=8A=B8=EB=9E=A9=20?= =?UTF-8?q?=EA=B9=A8=EC=A7=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _validate_sql_content 가 전체 줄 주석만 제거하고 인라인 주석(SQL -- ...)은 안 지워서, 365_scan_jobs 의 '-- commit 시 ...' 같은 설명 주석 단어를 트랜잭션 제어문으로 오탐 → fresh DB/DR 복원 시 부트스트랩 실패(verification env 실측). 줄별 -- 이후 제거로 근본 수정. Co-Authored-By: Claude Opus 4.8 (1M context) --- app/core/database.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/core/database.py b/app/core/database.py index cbf4052..674484f 100644 --- a/app/core/database.py +++ b/app/core/database.py @@ -57,12 +57,12 @@ def _parse_migration_files(migrations_dir: Path) -> list[tuple[int, str, Path]]: def _validate_sql_content(name: str, sql: str) -> None: """migration SQL에 BEGIN/COMMIT이 포함되어 있으면 에러 (외부 트랜잭션 깨짐 방지)""" - # 주석(-- ...) 라인 제거 후 검사 - lines = [ - line for line in sql.splitlines() - if not line.strip().startswith("--") - ] - stripped = "\n".join(lines).upper() + # 주석(전체 줄 + 인라인 `-- ...`) 제거 후 검사. ★인라인 주석을 안 지우면 설명 주석의 + # 'commit/begin' 단어(예 365_scan_jobs 의 `-- commit 시 documents.title 로 전파`)를 + # 트랜잭션 제어문으로 false-positive 로 잡아 fresh DB/DR 부트스트랩이 깨진다(verification + # 실측 2026-06). 줄별로 `--` 이후를 잘라 주석 텍스트를 검사에서 제외. + cleaned = [re.sub(r"--.*$", "", line) for line in sql.splitlines()] + stripped = "\n".join(cleaned).upper() for keyword in ("BEGIN", "COMMIT", "ROLLBACK"): # 단어 경계로 매칭 (예: BEGIN_SOMETHING은 제외) if re.search(rf"\b{keyword}\b", stripped):