Skip to content

fix(workspace/db): repair channels stuck at alembic 025 (missing orchestration columns)#558

Draft
zomux wants to merge 1 commit into
developfrom
worktree-workspace-bugfix
Draft

fix(workspace/db): repair channels stuck at alembic 025 (missing orchestration columns)#558
zomux wants to merge 1 commit into
developfrom
worktree-workspace-bugfix

Conversation

@zomux

@zomux zomux commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Production incident

workspace-backend prod was 500ing on every channel-list / /v1/discover query:

psycopg2.errors.UndefinedColumn: column channels.orchestration_mode does not exist

Root cause

Two migrations were both authored as revision 025:

  • 025_add_channel_orchestration (this lineage / develop / release) → adds channels.orchestration_mode + orchestration_instruction
  • 025_add_evaluation_jobs (experimental SWE-bench lineage) → creates evaluation_jobs

The prod DB had run the evaluation-jobs variant first and was stamped alembic_version='025'. When the orchestration code deployed, alembic upgrade head saw the DB already at 025 and became a no-op — so the orchestration columns were never created. Confirmed on prod: alembic_version='025' but orchestration% columns absent.

Fix

  • Prod DB already repaired live (idempotent ADD COLUMN IF NOT EXISTS); /v1/discover now returns 401 (auth) instead of 500. 17,071 channel rows intact.
  • This PR adds migration 026 that idempotently ensures both columns exist, so the alembic history is consistent and any other environment stuck at 025 self-repairs on next deploy. No-op where 025 applied cleanly.

Deploy

Fast-forward release from develop after merge; Railway preDeployCommand = alembic upgrade head will apply 026 (025→026, no-op DDL, stamps 026).

Follow-up (not in this PR)

The duplicate revision 025 should be de-conflicted at the source: the SWE-bench 025_add_evaluation_jobs needs renumbering before that lineage ever merges, or the collision recurs.

Verification

  • Reproduced the stuck state on a throwaway Postgres 15; 026's SQL creates the correct columns and is a clean no-op on re-run.
  • Prod endpoints that were 500ing now return 401 (past the DB layer).

🤖 Generated with Claude Code

…stration columns

Two migrations were both authored as revision "025":
  - 025_add_channel_orchestration (this lineage): adds
    channels.orchestration_mode + orchestration_instruction
  - 025_add_evaluation_jobs (experimental SWE-bench lineage): creates
    the evaluation_jobs table

Any DB that ran the evaluation-jobs variant first got stamped
alembic_version='025', so a later `alembic upgrade head` treated the DB
as already at head and never created the orchestration columns. Every
channel-list / /v1/discover query then 500s with
"column channels.orchestration_mode does not exist".

Add migration 026 that idempotently ensures both columns exist
(ADD COLUMN IF NOT EXISTS), repairing a DB stuck at 025 while being a
no-op where 025 already applied cleanly.
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openagents-workspace Ready Ready Preview, Comment Jul 9, 2026 7:33am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants