- confirm-req-implemented: REQ-001~018 (17건, REQ-013 제외) Approved → Implemented - BAT-001(REQ-009/011/014), BAT-002(REQ-010/012/015), BAT-003(REQ-001/002/003/006) - BAT-004(REQ-004/005), BAT-005(REQ-007/008), BAT-006(REQ-016/017/018) - CHG-20260521-01 entry 각 REQ에 추가; SRS index Recent Change Log 갱신 - REQ-010 CHG-20260521-02: GET /v1/assets admin catalog 전용 재정의 - 기존 token_type 분기 portfolio 조회 코드 제거, admin permission + list_assets() 호출로 대체 - AssetCatalogListResponse 스키마 추가 (items/total) - REQ-010 Status: Implemented → Approved (재검증 필요) - 테스트 343건 전체 통과: service/user token 403, admin token 200 + catalog schema 검증 - migration 보강: portfolios_asset_migration market 컬럼 부재 fallback, portfolio_tags 빈 테이블 early-return, service_token index fix autocommit_block 정리 - docs/releases/rel-001: REL-001 draft 추가 (BAT-001~011 포함) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5.6 KiB
5.6 KiB
REQ-014: portfolios 데이터 migration
- Status: Implemented
- Type: Migration
- Priority: High
- Owner: Justin Ko
Intent
- 기존
portfolios테이블의 운영 데이터를assetscatalog +portfolios포지션 구조로 유실 없이 이전한다. - migration은 단일 트랜잭션 내에서 원자적으로 실행되어야 하며 실패 시 롤백 가능해야 한다(NFR-1).
Requirement
- Alembic revision으로 아래 데이터 이전을 수행한다.
- 기존
portfolios행의symbol을 기준으로 중복 없이assetscatalog 항목을 생성한다. 동일 symbol의 모든market값을ARRAY_AGG(DISTINCT market)으로 집약하여assets.markets에 저장한다. market 값이 NULL인 기존 행은 빈 배열로 처리한다. - 각 portfolio 행에 생성된 asset의
asset_id FK를 연결한다. portfolios.managed_by_daemon_id는 기존 값을 그대로 유지한다.
- 기존
- migration 전
SELECT symbol, ARRAY_AGG(DISTINCT market) FROM portfolios GROUP BY symbol로 symbol별 market 집합을 파악하는 사전 검증 쿼리를 migration script에 포함한다. - 전체 이전 작업은 단일 트랜잭션으로 실행하며, 중간 실패 시 rollback되어 기존 상태로 복원된다.
- migration 완료 후
portfolios.symbol,portfolios.market컬럼을 제거한다(REQ-011과 동일 revision 또는 순서 보장된 revision에서 처리).
Acceptance Criteria
- Given migration 실행 전, When
SELECT COUNT(*) FROM portfolios로 기존 행 수 확인, Then migration 후 동일 행 수가 유지된다. - Given migration 실행 후, When
SELECT COUNT(*) FROM assets를 확인, Then 기존 portfolios의 고유 symbol 수와 일치하는 assets 행이 존재한다. - Given migration 실행 후, When 임의 portfolio 행의
asset_id로assets테이블을 JOIN 조회, Then 해당 asset의 symbol과 migration 전 portfolio의 symbol이 일치한다. - Given migration 실행 후, When
assets.markets를 확인, Then 동일 symbol을 가졌던 모든 market 값이 배열에 포함되어 있다. - Given migration 실행 중 오류 발생 시뮬레이션, When rollback 후 상태 확인, Then 기존 portfolios 데이터가 원상태로 보존된다.
- Given migration 완료 후, When
portfolios테이블 스키마 확인, Thensymbol,market컬럼이 존재하지 않는다.
Impacted Area
- Docs: 없음 (docs 갱신은 REQ-015에서 처리)
- Modules:
migrations/versions/— portfolios 데이터 이전 + symbol/market 컬럼 제거 Alembic revision
- Tests:
tests/test_asset_catalog.py(신규) — migration AC-1~6 검증- 기존 테스트 suite — migration 후 regression 검증
Notes
- R-1(High): 동일 symbol을 가진 여러 portfolio 행의 market 값이 서로 다를 수 있다.
ARRAY_AGG(DISTINCT market)집약 규칙을 migration script에 명시적으로 구현한다. - A-1(가정): 동일 symbol → 단일 assets 항목 병합, ARRAY_AGG(DISTINCT market) 집약, broker → 각 portfolio 행 유지.
- migration 전
SELECT COUNT(*) FROM portfolios WHERE managed_by_daemon_id IS NULL로 미배정 portfolio 현황을 파악하고, 필요한 경우 migration 전 daemon 배정 절차를 선행한다(R-3). - REQ-009(assets 테이블), REQ-011(portfolios 재설계) 선행 필요.
- Source: dcy-001 FR-6, NFR-1, R-1, A-1
Change Log
CHG-20260521-01
- Date: 2026-05-21
- Author: Justin Ko
Change Summary
- Status: Approved → Implemented
Intent
- BAT-001 confirm-batch-verification 완료. portfolios → assets catalog 데이터 이전 Alembic revision 구현. DB-integration ACs(1~6)는 실 DB 의존 — CI에서 migration 파일 구조 검증으로 대체, release 배포 시 alembic upgrade head로 최종 확인 예정.
Acceptance Criteria Delta
- No change
Impacted Area Delta
- No change
Delivery Trace Delta
- Batches:
- BAT-001
- Releases:
- REL-001
Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: implemented
- Follow-up Action: REL-001 배포 시 alembic upgrade 결과로 DB-integration AC 최종 확인
CHG-20260519-02
- Date: 2026-05-19
- Author: Justin Ko
Change Summary
- Status: Proposed → Approved
Intent
- 승인 게이트 통과: 필수 필드(Status/Type/Priority/Owner/Intent/Requirement/AC/Impacted Area/Change Log) 모두 충족, AC 구체성 확인 완료
Acceptance Criteria Delta
- No change
Impacted Area Delta
- No change
Delivery Trace Delta
- Batches:
- none (미정)
- Releases:
- none (미정)
Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: promote-to-approved
- Follow-up Action: batch 계획 편입
CHG-20260519-01
- Date: 2026-05-19
- Author: Justin Ko
Change Summary
- 최초 생성 — dcy-001 confirm-discovery 후 draft-req 실행
Intent
- dcy-001 FR-6, NFR-1을 Migration REQ로 분리; portfolios 데이터 이전 및 원자적 실행 정의
Acceptance Criteria Delta
- Added:
- AC-1~6 최초 작성
Impacted Area Delta
- Docs:
- 없음
- Modules:
- migrations/versions/ — 최초 지정
- Tests:
- tests/test_asset_catalog.py, 기존 테스트 suite — 최초 지정
Delivery Trace Delta
- Batches:
- none (미정)
- Releases:
- none (미정)
Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: keep-current
- Follow-up Action: confirm-req 후 batch 계획 편입; REQ-009, REQ-011 선행 의존성 확인
Validation Plan
- pytest로 AC-1~6 검증; 트랜잭션 rollback은 savepoint 또는 테스트 DB 격리로 시뮬레이션