mirror of
https://github.com/coder/coder.git
synced 2026-06-03 13:08:25 +00:00
2132c53f28
Creates migration 000409 with the database foundation for pausing and resuming task workspaces. The task_snapshots table stores conversation history (AgentAPI messages) so users can view task logs even when the workspace is stopped. Each task gets one snapshot, overwritten on each pause. Three new build_reason values (task_auto_pause, task_manual_pause, task_resume) let us distinguish task lifecycle events in telemetry and audit logs from regular workspace operations. Uses a regular table rather than UNLOGGED for snapshots. While UNLOGGED would be faster, losing snapshots on database crash creates user confusion (logs disappear until next pause). We can switch to UNLOGGED post-GA if write performance becomes a problem. Closes coder/internal#1250
17 lines
811 B
SQL
17 lines
811 B
SQL
INSERT INTO task_snapshots VALUES (
|
|
'f5a1c3e4-8b2d-4f6a-9d7e-2a8b5c9e1f3d', -- task_id (references existing task from 000366)
|
|
'{
|
|
"format": "agentapi",
|
|
"data": {
|
|
"messages": [
|
|
{"id": 0, "type": "output", "content": "Starting task execution...", "time": "2024-11-02T13:10:05Z"},
|
|
{"id": 1, "type": "input", "content": "Create a React component for tasks", "time": "2024-11-02T13:10:06Z"},
|
|
{"id": 2, "type": "output", "content": "Creating component structure...", "time": "2024-11-02T13:10:10Z"}
|
|
],
|
|
"truncated": false,
|
|
"total_count": 3
|
|
}
|
|
}'::JSONB, -- log_snapshot
|
|
'2024-11-02 13:15:00.000000+02' -- log_snapshot_at
|
|
) ON CONFLICT DO NOTHING;
|