4.2 KiB
4.2 KiB
BAT-025 Implementation Log
- Date: 2026-07-15
- Assignee: dev-impl
- Scope: REQ-057
portfolio_ledger수동 장부 메타데이터의 명시 Alembic migration - Implementation state: remediation complete; independent QC pending
Baseline and remediation provenance
- Initial implementation baseline:
f6195ff8090d8761d467e15f44255642ca350e80. - The previously recorded SHA
850e970does not identify the reviewed implementation and is superseded by the baseline above. - The remediation below is deliberately uncommitted in this worktree. No push, PR, main merge, production migration, deployment, or service activation was performed.
Implemented changes
-
Explicit revision
20260715_0028remains the REQ-057 head.- Parent:
20260628_0027. - Adds
source,target_ledger_entry_id,confirmation_evidence, andactor_user_idadditively. - Handles runtime-precreated columns by backfilling nullable
source, then converging its default andNOT NULLconstraint. - Downgrade remains a forward-only no-op; no column deletion was added.
- Parent:
-
Remediation of actual PostgreSQL migration-chain/runtime behavior.
migrations/versions/20260605_0025_ledger_consolidation.py: makes the identityledger_entry_idexplicitlynullable=False. PostgreSQL identity columns are implicitly non-null; the prior explicit trailingNULLwas incompatible with fresh real-PostgreSQL migration.app/db/migrations.py: programmatic Alembic configuration now carries the caller-providedSettings. For a legacy/runtime-precreated schema, bootstrap stamps20260628_0027and then executesupgrade head, so revision0028performs its required source backfill/default/constraint convergence instead of being skipped by a direct head stamp.migrations/env.py: consumes the explicit settings when supplied and preserves existing application loggers when Alembic runs in-process.
-
Real isolated PostgreSQL integration coverage.
tests/test_bat025_portfolio_ledger_manual_metadata_migration.pycreates a UUID-named temporary database only through an explicitly supplied loopbackpostgresmaintenance DSN.- The test rejects non-loopback hosts and any maintenance database other than
postgres; each test terminates connections and drops only its own UUID-named database. - Coverage includes pre-0028 upgrade/data preservation, runtime-precreated nullable
sourceconvergence and Alembic current-head state, plus representative broker/manual ledger writes after upgrade.
-
Existing operation runbook is retained.
docs/runbooks/bat-025-req057-portfolio-ledger-manual-metadata-runbook.md- It remains a runbook only; no production command in it was executed.
Executed evidence
All commands below used the local Docker PostgreSQL service only. The DSN was supplied from an environment variable and is intentionally omitted here.
BAT025_LOCAL_POSTGRES_DSN=[REDACTED local loopback maintenance DSN] PYTHONPATH=. uv run --extra dev --with httpx2 python -m pytest -q --override-ini addopts='' -p no:cacheprovider tests/test_bat025_portfolio_ledger_manual_metadata_migration.py- Result: 3 passed in 6.10s.
- Verifies real 0027→0028 data preservation/source backfill, runtime-precreated compatibility/current revision, and broker/manual write regression in throwaway DBs.
PYTHONPATH=. uv run --extra dev --with httpx2 python -m pytest -q --override-ini addopts='' -p no:cacheprovider- Result: 597 passed, 11 warnings in 41.41s.
- Warnings are pre-existing Starlette
HTTP_422_UNPROCESSABLE_ENTITYdeprecations in endpoint tests; no test failed.
uv run --extra dev ruff check app/db/migrations.py migrations/env.py migrations/versions/20260605_0025_ledger_consolidation.py tests/test_bat025_portfolio_ledger_manual_metadata_migration.py- Result: All checks passed.
python3 -m compileall -q app migrationsandgit diff --check- Result: exit 0.
Limits / non-claims
- This evidence is for isolated local PostgreSQL only; it is not an operational DB upgrade.
- Lock contention, backup restore, production access control, deployment, service activation, and M5 release remain unexecuted.
- This log is developer evidence only. It does not mark BAT-025 verified or approved; independent QC remains required.