diff --git a/app/repositories/postgres.py b/app/repositories/postgres.py index b8e691c..4422097 100644 --- a/app/repositories/postgres.py +++ b/app/repositories/postgres.py @@ -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,)) diff --git a/docs/db-schema-spec.md b/docs/db-schema-spec.md index 532fde5..0f1f9ed 100644 --- a/docs/db-schema-spec.md +++ b/docs/db-schema-spec.md @@ -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