Skip to content

Tasks: Database migrations for task lifecycle #1250

Closed
coder/coder
#21557

Description

@mafredri

Repo: coder/coder

Scope: Add schema support for log snapshots and task-specific build reasons.

Changes:

  • Create task_snapshots table (consider UNLOGGED; data is ephemeral, best-effort, regenerated on each pause):
    • task_id UUID PRIMARY KEY REFERENCES tasks(id) ON DELETE CASCADE
    • log_snapshot JSONB NOT NULL
      • Wrapper schema: {"format":"agentapi","data":<raw_agentapi_payload>}
    • log_snapshot_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
  • Add build reason enum values: task_auto_pause, task_manual_pause, task_resume

Files:

  • New migration in coderd/database/migrations/
  • coderd/database/dump.sql
  • Run make gen
  • Update enterprise/audit/table.go if needed

Acceptance criteria:

  • Migration runs without error on fresh and existing databases
  • make gen succeeds
  • make lint passes
  • Build reasons available in database.BuildReason enum

Dependencies: None

References:

Activity

  1. added theissue type on Jan 15, 2026
  2. self-assigned this
    on Jan 19, 2026
  3. added a commit that references this issue on Jan 21, 2026
    2132c53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions