feat(db): add created_by column to chat_messages table (#22940)

Adds a `created_by` column (nullable UUID) to the `chat_messages` table
to track which user created each message. Only user-sent messages
populate this field; assistant, tool, system, and summary messages leave
it null.

The column is threaded through the full stack: SQL migration, query
updates, generated Go/TypeScript types, db2sdk conversion, chatd
(including subagent paths), and API handlers. All API handlers that
insert user messages now pass the authenticated user's ID as
`created_by`.

No foreign key constraint was added, matching the existing pattern used
by `chat_model_configs.created_by`.
This commit is contained in:
Kyle Carberry
2026-03-11 07:00:38 -07:00
committed by GitHub
parent c7c789f9e4
commit bb59477648
12 changed files with 66 additions and 15 deletions
+1
View File
@@ -3952,6 +3952,7 @@ type ChatMessage struct {
CacheReadTokens sql.NullInt64 `db:"cache_read_tokens" json:"cache_read_tokens"`
ContextLimit sql.NullInt64 `db:"context_limit" json:"context_limit"`
Compressed bool `db:"compressed" json:"compressed"`
CreatedBy uuid.NullUUID `db:"created_by" json:"created_by"`
}
type ChatModelConfig struct {