Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions backend/internal/infra/persistence/models/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,19 @@ type ChatRunEvent struct {
UserID uint `gorm:"not null;default:0;index:idx_chat_run_events_user_id;comment:用户ID"`
RunID string `gorm:"size:64;not null;default:'';index:idx_chat_run_events_run_id;uniqueIndex:uk_chat_run_events_run_scope_event,priority:1;comment:运行ID"`
EventScope string `gorm:"size:32;not null;default:'';index:idx_chat_run_events_scope;uniqueIndex:uk_chat_run_events_run_scope_event,priority:2;comment:事件范围(trace_block/trace_event/tool_call)"`
EventID string `gorm:"size:96;not null;default:'';uniqueIndex:uk_chat_run_events_run_scope_event,priority:3;comment:事件ID"`
EventID string `gorm:"size:255;not null;default:'';uniqueIndex:uk_chat_run_events_run_scope_event,priority:3;comment:事件ID"`
EventType string `gorm:"size:32;not null;default:'';index:idx_chat_run_events_type;comment:事件类型"`
Phase string `gorm:"size:32;not null;default:'';index:idx_chat_run_events_phase;comment:阶段(process/tools/upstream_think)"`
Stage string `gorm:"size:32;not null;default:'';index:idx_chat_run_events_stage;comment:链路阶段(process/think/tool/answer)"`
RoundID string `gorm:"size:64;not null;default:'';index:idx_chat_run_events_round_id;comment:链路轮次ID"`
ParentEventID string `gorm:"size:96;not null;default:'';index:idx_chat_run_events_parent_event_id;comment:父事件ID"`
ParentEventID string `gorm:"size:255;not null;default:'';index:idx_chat_run_events_parent_event_id;comment:父事件ID"`
Status string `gorm:"size:32;not null;default:'';index:idx_chat_run_events_status;comment:事件状态(streaming/completed/error)"`
Title string `gorm:"size:64;not null;default:'';comment:轨迹标题"`
Title string `gorm:"size:255;not null;default:'';comment:轨迹标题"`
Summary string `gorm:"size:255;not null;default:'';comment:轨迹摘要"`
ContentMarkdown string `gorm:"type:text;not null;default:'';comment:轨迹Markdown内容"`
PayloadJSON string `gorm:"type:text;not null;default:'';comment:轨迹负载JSON"`
Seq int `gorm:"not null;default:0;index:idx_chat_run_events_seq;comment:事件顺序"`
ToolCallID string `gorm:"size:64;not null;default:'';index:idx_chat_run_events_tool_call_id;comment:工具调用ID"`
ToolCallID string `gorm:"size:255;not null;default:'';index:idx_chat_run_events_tool_call_id;comment:工具调用ID"`
ToolName string `gorm:"size:128;not null;default:'';index:idx_chat_run_events_tool_name;comment:工具名称"`
LatencyMS int64 `gorm:"not null;default:0;comment:调用时长毫秒"`
InputJSON string `gorm:"type:text;not null;default:'';comment:输入JSON"`
Expand Down
9 changes: 9 additions & 0 deletions backend/internal/infra/persistence/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,15 @@ func applyConversationBaselineIndexes(db *gorm.DB) error {
`COMMENT ON COLUMN "chat_runs"."task_type" IS '任务类型'`,
`CREATE INDEX IF NOT EXISTS idx_chat_runs_task_type
ON "chat_runs" ("task_type")`,
`ALTER TABLE "chat_run_events"
ALTER COLUMN "event_id" TYPE varchar(255),
ALTER COLUMN "parent_event_id" TYPE varchar(255),
ALTER COLUMN "title" TYPE varchar(255),
ALTER COLUMN "tool_call_id" TYPE varchar(255)`,
`COMMENT ON COLUMN "chat_run_events"."event_id" IS '事件ID'`,
`COMMENT ON COLUMN "chat_run_events"."parent_event_id" IS '父事件ID'`,
`COMMENT ON COLUMN "chat_run_events"."title" IS '轨迹标题'`,
`COMMENT ON COLUMN "chat_run_events"."tool_call_id" IS '工具调用ID'`,
`CREATE UNIQUE INDEX IF NOT EXISTS uk_file_objects_active_user_content
ON "file_objects" ("user_id", "sha256", "size_bytes")
WHERE status = 'active' AND deleted_at IS NULL AND sha256 <> ''`,
Expand Down
Loading