Skip to content

A1: DB ORM 무결성 + ABM 캐시 로그 동기화#192

Merged
bat1120 merged 1 commit into
devfrom
feat/a1-db-integrity-fixes
May 5, 2026
Merged

A1: DB ORM 무결성 + ABM 캐시 로그 동기화#192
bat1120 merged 1 commit into
devfrom
feat/a1-db-integrity-fixes

Conversation

@bat1120

@bat1120 bat1120 commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

A1 영역 (backend/database, services) 한정 ORM 무결성 fix.

DB 마이그레이션은 이미 적용됨. ORM drift 동기화 + nullable 정책 명시.

주요 변경

1. JeonseMonthlyRent FK 동기화

  • dong_code String(15) → String(10) + ForeignKey(jeonse_dong_master.dong_code)
  • 근거: alembic f3c4d5e6a7b8 에서 NOT VALID + VALIDATE 완료. ORM 만 drift

2. Seoul 9개 자식 테이블 ForeignKey 동기화

  • 대상: SeoulDistrictSales, SeoulDistrictStores, SeoulGolmokRent, SeoulPopulationQuarterly, SeoulTrainingDataset, DistrictSalesSeoul, SeoulAdstrdChangeIx, SeoulAdstrdFlpop, SeoulAdstrdStor
  • ForeignKey(seoul_dong_master.dong_code, onupdate=CASCADE) 추가
  • 근거: alembic e2b3c4d5f6a7 에서 11개 테이블 NOT VALID + VALIDATE 완료
  • column type 그대로 유지 (Text / VARCHAR(15) → VARCHAR(8) PK 참조 — PostgreSQL string family 호환)

3. User / ManagerUser nullable 명시

  • User: plan, agree_terms, is_active, email_verified
  • ManagerUser: is_active, is_approved, email_verified
  • DB 레벨 NOT NULL DEFAULT 와 ORM 동기화 (드리프트 해소)

4. ABM 캐시 로그 메시지 fix

위험도

낮음 — DB 변경 0건. ORM-only 동기화. 기존 데이터 영향 0.

미포함 (별도 PR)

  • IndustryMaster ORM FK (자식 6개 Text + 6개 String(20) 혼합 — DB 마이그레이션 필요)
  • ABM legal same_brand_500m 데이터 누락 (다른 담당)
  • Redis HyDE 캐시 누수 (chains/retriever.py — legal agent 영역)

Test plan

  • python -c "from src.database.models import Base; print('ORM OK')" — ORM 컴파일 확인
  • alembic 마이그레이션 추가 없음 → alembic upgrade head no-op
  • 기존 쿼리 회귀 없음 (FK 추가는 SELECT 쿼리에 영향 없음)

🤖 Generated with Claude Code

models.py:
- JeonseMonthlyRent.dong_code: String(15) → String(10) + ForeignKey(jeonse_dong_master.dong_code)
  · alembic f3c4d5e6a7b8 에서 DB FK 추가 완료, ORM drift 동기화
- 9개 자식 테이블 ForeignKey(seoul_dong_master.dong_code) 추가
  · alembic e2b3c4d5f6a7 에서 DB FK 추가 완료, ORM 동기화
  · 대상: SeoulDistrictSales, SeoulDistrictStores, SeoulGolmokRent,
    SeoulPopulationQuarterly, SeoulTrainingDataset, DistrictSalesSeoul,
    SeoulAdstrdChangeIx, SeoulAdstrdFlpop, SeoulAdstrdStor
  · column type 그대로 유지 (PostgreSQL string family 호환)
- User / ManagerUser nullable 명시:
  · User.plan / agree_terms / is_active / email_verified
  · ManagerUser.is_active / is_approved / email_verified
  · DB 레벨 NOT NULL DEFAULT 와 ORM 동기화

abm_simulation_service.py:
- L241 redis SET 로그 메시지 ttl=3600s → ttl=86400s
  · L240 setex(86400) 와 일치 (PR #186 main.py 와 동일 fix)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bat1120 bat1120 merged commit 2bbe9db into dev May 5, 2026
1 check passed
@bat1120 bat1120 deleted the feat/a1-db-integrity-fixes branch May 5, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant