Skip to content

A1: industry_master ORM ForeignKey 배선 + InviteCode nullable#194

Merged
bat1120 merged 1 commit into
devfrom
feat/a1-orm-cleanup-followup
May 5, 2026
Merged

A1: industry_master ORM ForeignKey 배선 + InviteCode nullable#194
bat1120 merged 1 commit into
devfrom
feat/a1-orm-cleanup-followup

Conversation

@bat1120

@bat1120 bat1120 commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

A1 영역 ORM 무결성 후속 fix.

주요 변경

IndustryMaster docstring 정정

  • 잘못된 claim "DB 측 FK constraint 9개" 제거
  • alembic 마이그레이션 검색 결과 0건 — DB FK 미존재 (2026-05-05 검증)
  • 자식 13개 industry_code type 분포 명시:
    • String(20): 8개 (GolmokCommercial, DistrictSales, StoreQuarterly, DistrictSalesSeoul, SeoulAdstrdStor, SeoulSignguSelng, SeoulSignguStor)
    • Text: 5개 (GolmokSales, GolmokStores, SeoulDistrictSales, SeoulDistrictStores, SeoulTrainingDataset)

자식 12개 ORM ForeignKey 배선

  • 모든 자식 industry_code 컬럼에 ForeignKey("industry_master.industry_code", onupdate="CASCADE") 추가
  • DB type 그대로 유지 (PostgreSQL string family — Text/VARCHAR 모두 String(20) PK 참조 가능)
  • ORM relationship/lazy loading 가능 → N+1 query 회피

InviteCode nullable 명시

미포함 (별도 PR)

  • DB 레벨 FK constraint 추가 (alembic 마이그레이션 + NOT VALID + VALIDATE)
  • Text → String(20) DB 마이그레이션 (production data 검증 필요)

위험도

낮음 — ORM-only 변경. DB 변경 0건. SQLAlchemy 컴파일 검증 완료.

Test plan

  • python -c "from src.database.models import IndustryMaster, GolmokSales; print('OK')" ORM 컴파일 확인
  • alembic head 변경 없음 → alembic upgrade head no-op
  • 기존 SELECT 쿼리 회귀 없음

🤖 Generated with Claude Code

models.py:
- IndustryMaster docstring 정정:
  · 잘못된 claim "DB FK 9개" 제거 (alembic 검색 결과 0건)
  · 자식 13개 type 분포 명시 (8 String(20) + 5 Text)
- 자식 12개 industry_code 컬럼에 ForeignKey(industry_master.industry_code) 추가:
  · String(20): GolmokCommercial, DistrictSales, StoreQuarterly,
    DistrictSalesSeoul, SeoulAdstrdStor, SeoulSignguSelng, SeoulSignguStor
  · Text: GolmokSales, GolmokStores, SeoulDistrictSales,
    SeoulDistrictStores, SeoulTrainingDataset
  · DB type 그대로 유지 (PostgreSQL string family 호환)
  · DB FK constraint 미존재 → ORM-level 만 동기 (DB 마이그레이션 별도 PR)
- InviteCode nullable 명시:
  · max_uses, used_count, is_active 에 nullable=False
  · DB default 와 ORM 동기화 (드리프트 해소)

위험도: 낮음. ORM-only 변경. DB 변경 0건.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bat1120 bat1120 merged commit 6cbfdcf into dev May 5, 2026
1 check passed
@bat1120 bat1120 deleted the feat/a1-orm-cleanup-followup branch May 5, 2026 02:12
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