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):