mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -49,6 +49,7 @@ type Chat struct {
|
||||
type ChatMessage struct {
|
||||
ID int64 `json:"id"`
|
||||
ChatID uuid.UUID `json:"chat_id" format:"uuid"`
|
||||
CreatedBy *uuid.UUID `json:"created_by,omitempty" format:"uuid"`
|
||||
ModelConfigID *uuid.UUID `json:"model_config_id,omitempty" format:"uuid"`
|
||||
CreatedAt time.Time `json:"created_at" format:"date-time"`
|
||||
Role string `json:"role"`
|
||||
|
||||
Reference in New Issue
Block a user