docs: add cascade delete note to db-schema-spec and improve delete_comment in postgres.py

Agent-Logs-Url: https://github.com/genichin/portfolio-hub/sessions/64fc2cec-78f5-41d1-99a4-45f868781edd

Co-authored-by: genichin <4282227+genichin@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-10 13:56:08 +00:00
committed by GitHub
co-authored by genichin
parent e8f782bec6
commit 1a36bcd826
2 changed files with 3 additions and 0 deletions
+1
View File
@@ -1190,6 +1190,7 @@ class PostgresPortfolioRepository:
raise ValueError("포트폴리오를 찾을 수 없습니다")
if clear_ledger:
cur.execute("DELETE FROM portfolio_ledger WHERE portfolio_id = %s", (portfolio_id,))
# Comments are always removed with the portfolio (no FK constraint, handled in application layer)
cur.execute("DELETE FROM portfolio_comments WHERE portfolio_id = %s", (portfolio_id,))
cur.execute("DELETE FROM portfolios WHERE portfolio_id = %s", (portfolio_id,))
+2
View File
@@ -306,6 +306,8 @@ Current baseline intentionally has no DB-level FK constraints.
- Logical relations are managed by application/repository logic.
- When adding FK constraints in future migrations, update this document and include migration IDs.
- Cascade behavior implemented in application layer:
- Deleting a portfolio also deletes all associated `portfolio_comments` rows (hard delete, no FK constraint).
## 8. Change Management Rule