Replace sqlc with hand-written queries on sqlx #1007

Open
opened 2026-10-27 13:38:39 +00:00 by sam · 0 comments
Owner

Persistence uses sqlc: SQL in internal/infrastructure/postgres/queries/*.sql is compiled into ~6,200 lines of generated Go in postgresdb/, used by 15 files. That needs the sqlc tool in tools/go.mod, sqlc.yaml, task db:generate and the db:check gate step, and a regenerate step on every query change. The maintainer prefers plain SQL migrations plus sqlx.

Change:

  • Keep the goose migrations (internal/infrastructure/postgres/migrations) as the schema source.
  • Move each query into the store method that uses it, as a SQL string executed with sqlx (Get/Select/NamedExec over structs with db tags), in place of the generated postgresdb calls.
  • Delete postgresdb/, queries/, sqlc.yaml, the sqlc tool dependency, task db:generate and the db:check step in task check.
  • Remove sqlc from CLAUDE.md's generated-files rule.

Do it store file by store file; behaviour must not change. The State Store SQL semantics (transition guards, idempotent dispatch, cancellation) are a listed test seam: add a test only where a converted query actually breaks.

Acceptance criteria

No sqlc dependency, config or generated code remains; every store method runs its own SQL through sqlx; task check passes without db:check; the State Store starts against a migrated database and serves tasks.


Imported from beads archie-core-1rwj · GitHub #1332 · type task · priority P2 · created 2026-10-03

Persistence uses sqlc: SQL in internal/infrastructure/postgres/queries/*.sql is compiled into ~6,200 lines of generated Go in postgresdb/, used by 15 files. That needs the sqlc tool in tools/go.mod, sqlc.yaml, task db:generate and the db:check gate step, and a regenerate step on every query change. The maintainer prefers plain SQL migrations plus sqlx. Change: - Keep the goose migrations (internal/infrastructure/postgres/migrations) as the schema source. - Move each query into the store method that uses it, as a SQL string executed with sqlx (Get/Select/NamedExec over structs with db tags), in place of the generated postgresdb calls. - Delete postgresdb/, queries/, sqlc.yaml, the sqlc tool dependency, task db:generate and the db:check step in task check. - Remove sqlc from CLAUDE.md's generated-files rule. Do it store file by store file; behaviour must not change. The State Store SQL semantics (transition guards, idempotent dispatch, cancellation) are a listed test seam: add a test only where a converted query actually breaks. ### Acceptance criteria No sqlc dependency, config or generated code remains; every store method runs its own SQL through sqlx; task check passes without db:check; the State Store starts against a migrated database and serves tasks. --- _Imported from beads `archie-core-1rwj` · GitHub #1332 · type task · priority P2 · created 2026-10-03_
sam added the mediumtask labels 2026-10-27 13:38:39 +00:00
sam self-assigned this 2026-10-27 13:38:39 +00:00
sam added the deferred label 2026-11-15 17:26:23 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1007