Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(db): relax pending task unique index to per-(issue, agent) (#637)

Jiayuan Zhangbf8abba24d82
diff --git a/server/migrations/037_fix_pending_task_unique_index.down.sql b/server/migrations/037_fix_pending_task_unique_index.down.sql
new file mode 100644
index 0000000000..18b6a7e9a7
--- /dev/null
+++ b/server/migrations/037_fix_pending_task_unique_index.down.sql
@@ -0,0 +1,5 @@
+DROP INDEX IF EXISTS idx_one_pending_task_per_issue_agent;
+
+CREATE UNIQUE INDEX idx_one_pending_task_per_issue
+ ON agent_task_queue (issue_id)
+ WHERE status IN ('queued', 'dispatched');
diff --git a/server/migrations/037_fix_pending_task_unique_index.up.sql b/server/migrations/037_fix_pending_task_unique_index.up.sql
new file mode 100644
index 0000000000..e7e4466c0c
--- /dev/null
+++ b/server/migrations/037_fix_pending_task_unique_index.up.sql
@@ -0,0 +1,8 @@
+-- Fix: the old index only allowed one pending task per issue across ALL agents.
+-- This caused different agents' pending tasks to block each other.
+-- Change to per-(issue, agent) so each agent can independently have one pending task.
+DROP INDEX IF EXISTS idx_one_pending_task_per_issue;
+
+CREATE UNIQUE INDEX idx_one_pending_task_per_issue_agent
+ ON agent_task_queue (issue_id, agent_id)
+ WHERE status IN ('queued', 'dispatched');