Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
fix ON CONFLICT (again)
Dane Schneider7fc9836e996a
diff --git a/app/server/db/locks.go b/app/server/db/locks.goindex 87c64605..bea0442b 100644--- a/app/server/db/locks.go+++ b/app/server/db/locks.go@@ -303,7 +303,10 @@ func lockRepo(params LockRepoParams, numRetry int) (string, error) {var insertedId sql.NullString- insertQuery := "INSERT INTO repo_locks (org_id, user_id, plan_id, plan_build_id, scope, branch) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id ON CONFLICT ON CONSTRAINT repo_locks_plan_branch_write DO NOTHING"+ insertQuery := "INSERT INTO repo_locks (org_id, user_id, plan_id, plan_build_id, scope, branch) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (plan_id) WHERE scope = 'w' DO NOTHING RETURNING id"++ log.Printf("Insert query: %s", insertQuery)+err = tx.QueryRow(insertQuery,newLock.OrgId,diff --git a/app/server/migrations/2025021101_locks_unique.up.sql b/app/server/migrations/2025021101_locks_unique.up.sqlindex 4e275a46..528755be 100644--- a/app/server/migrations/2025021101_locks_unique.up.sql+++ b/app/server/migrations/2025021101_locks_unique.up.sql@@ -1,6 +1,6 @@CREATE UNIQUE INDEX repo_locks_single_write_lock- ON repo_locks (plan_id)+ ON repo_locks(plan_id)WHERE (scope = 'w');CREATE TABLE IF NOT EXISTS lockable_plan_ids (