feat(REQ-001): add portfolio comment history API, CLI, repository, migration, and tests
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:
co-authored by
genichin
parent
4684597353
commit
e8f782bec6
+33
-2
@@ -5,7 +5,7 @@
|
||||
This document defines the database schema in an AI-agent-friendly format.
|
||||
|
||||
- Source of truth: Alembic revisions in `migrations/versions`
|
||||
- Current baseline revision: `20260403_0008`
|
||||
- Current baseline revision: `20260410_0009`
|
||||
- Baseline files:
|
||||
- `migrations/versions/20260403_0001_initial_portfolio_schema.py`
|
||||
- `migrations/versions/20260403_0002_strategy_set_columns.py`
|
||||
@@ -15,6 +15,7 @@ This document defines the database schema in an AI-agent-friendly format.
|
||||
- `migrations/versions/20260403_0006_bot_principals_and_bot_tokens.py`
|
||||
- `migrations/versions/20260403_0007_bot_principal_permission_only.py`
|
||||
- `migrations/versions/20260403_0008_portfolio_name_column.py`
|
||||
- `migrations/versions/20260410_0009_portfolio_comments_table.py`
|
||||
|
||||
## 2. Scope
|
||||
|
||||
@@ -26,6 +27,7 @@ Schema objects covered by baseline revision:
|
||||
- `bot_principals`
|
||||
- `portfolios`
|
||||
- `portfolio_ledger`
|
||||
- `portfolio_comments`
|
||||
- secondary indexes
|
||||
- Timescale hypertable conversion rule for `portfolio_ledger`
|
||||
|
||||
@@ -206,6 +208,29 @@ Constraints:
|
||||
- Primary key: none in baseline
|
||||
- Foreign key constraints: none in baseline
|
||||
|
||||
### 4.6 portfolio_comments
|
||||
|
||||
Purpose:
|
||||
|
||||
- Stores user-authored comment history per portfolio for memo/annotation tracking.
|
||||
- Supports multiline text content.
|
||||
- Comments are isolated per portfolio and listed in reverse chronological order.
|
||||
|
||||
Columns:
|
||||
|
||||
| Column | Type | Null | Default | Constraints / Notes |
|
||||
|---|---|---|---|---|
|
||||
| id | Text | NO | - | Primary Key (UUID) |
|
||||
| portfolio_id | Text | NO | - | Logical reference to `portfolios.portfolio_id` (no FK) |
|
||||
| content | Text | NO | - | Comment text; supports multiline |
|
||||
| created_at | DateTime(timezone=True) | NO | NOW() | Creation timestamp |
|
||||
| updated_at | DateTime(timezone=True) | NO | NOW() | Last update timestamp |
|
||||
|
||||
Constraints:
|
||||
|
||||
- Primary key: `id`
|
||||
- Foreign key constraints: none
|
||||
|
||||
## 5. Indexes
|
||||
|
||||
### 5.1 ix_users_created_at
|
||||
@@ -257,7 +282,12 @@ Constraints:
|
||||
- Unique: no
|
||||
- Intent: speed list/filter queries by broker/status and recency.
|
||||
|
||||
## 6. TimescaleDB Behavior
|
||||
### 5.8 idx_portfolio_comments_portfolio_created
|
||||
|
||||
- Table: `portfolio_comments`
|
||||
- Columns/expressions: (`portfolio_id`, `created_at DESC`)
|
||||
- Unique: no
|
||||
- Intent: fetch comments per portfolio efficiently in reverse chronological order.
|
||||
|
||||
Conditional behavior in migration upgrade:
|
||||
|
||||
@@ -297,3 +327,4 @@ When schema changes:
|
||||
| 20260403_0006 | migrations/versions/20260403_0006_bot_principals_and_bot_tokens.py | Add `bot_principals` table and `auth_tokens.bot_principal_id` for bot API key management |
|
||||
| 20260403_0007 | migrations/versions/20260403_0007_bot_principal_permission_only.py | Remove `bot_principals.owner_user_id` and enforce bot-local `permission` model |
|
||||
| 20260403_0008 | migrations/versions/20260403_0008_portfolio_name_column.py | Add non-null `portfolios.name` (asset display name), backfilled from `symbol` |
|
||||
| 20260410_0009 | migrations/versions/20260410_0009_portfolio_comments_table.py | Add `portfolio_comments` table for per-portfolio memo/comment history |
|
||||
|
||||
Reference in New Issue
Block a user