published fresh until

sqlc, GORM, ent, Bun or pgx for Go data access and migrations?

Summary As of October 2026, choose sqlc with pgx and goose for SQL-owned Postgres queries and explicit migrations; GORM for convenient CRUD, ent for generated entity APIs, Bun for SQL-shaped builders, or pgx directly for manual control. Atlas adds schema planning, with edition and licence limits (checked 2026-10-20).

Not for backend language or small VPS framework selection, see go-or-rust-or-elixir-for-a-backend-on-a-small-vps

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

Choose a Go data layer for filters, joins and transactions, then a schema upgrade workflow. sqlc generates query code; pgx runs Postgres queries; ORMs model data; migrators change schema. sqlc and pgx work together.

Versions, licences and cost, checked 2026-10-20

Fetched releases and repository licences; not installed.

OptionReleaseLicence / cost boundary
sqlc1.31.1MIT; local generator has no licence fee
GORM1.31.2MIT
ent0.14.6Apache-2.0
Bun1.3.0BSD-2-Clause
pgx5.11.0MIT
goose3.29.0MIT
golang-migrate4.20.1MIT
Atlas1.3.0Community binaries Apache-2.0; default binaries under Ariga MSA

Atlas pricing, checked 2026-10-20, lists Starter free and Pro from $9/developer/month plus CI/CD and database usage. Linting and drift monitoring appear in Pro. Community, Starter and Pro differ in features and terms.

When to pick which data layer

PickGood fitCost you accept
sqlc + pgxPostgres, SQL-literate team, known queries, joins and reports checked during generationRegeneration after schema/query edits; custom types and genuinely dynamic query shapes need deliberate handling
GORMCRUD, associations, hooks and a team wanting a familiar ORM APIInspect generated SQL, eager loading and update semantics; model convenience does not remove database knowledge
entLarge entity graph, Go-defined schemas and generated typed traversal APIsGenerated code and a code-generation workflow; SQL escape hatches and migration planning still need review
BunYou want SQL-shaped query construction, struct scanning and relationsRuntime query construction and mapping; it is a Go ORM, unrelated to the JavaScript runtime
pgx directlyPostgres-specific COPY, LISTEN/NOTIFY, handwritten queries or very few query methodsOwn the mapping, query tests and transaction plumbing; it is not an ORM or migrator

sqlc's pgx guide shows generated methods using pgx. Keep most queries generated and put the few dynamic ones behind an explicit repository method if necessary. Bind values; allowlist sortable columns instead of interpolating user input. Neither code generation nor an ORM proves that a query uses the right index.

Choose migrations independently

PickUse whenBoundary
gooseTeam wants reviewed incremental SQL, optionally Go migration functions and embeddingGo migrations require a custom Go binary; do not assume every replica can safely migrate at startup
golang-migrateExisting up/down SQL files, CLI or Go library, broad source/database adaptersSeparate migration runner; a failed migration needs investigation before marking a version clean
AtlasDesired schema comes from SQL/HCL or ORM models and you want generated versioned diffsReview the diff, development database requirements and exact edition before relying on lint/drift features

sqlc does not execute migrations; it can read migration directories, ignores down statements and warns about numeric versus lexicographic file ordering. GORM AutoMigrate creates missing objects and changes some column definitions, but will not delete unused columns. It is not a reviewed deployment history. ent versioned migrations integrate Atlas; generated SQL still deserves review.

For an Atlas-like workflow without its planning service, keep reviewed SQL migrations in version control and rehearse on a disposable database. goose/migrate execute files but do not automatically diff schemas. Postgres-only jackc/tern is another SQL migrator. Give schema changes one deployment owner; use expand/backfill/contract for incompatible changes. Goose's provider docs say locking is off by default and document a session locker.

What the community says

  • In sqlc issue 3414, kyleconroy carries forward mehdijoafshani's request for “dynamic filters” and sorting. The fetched issue is open. This is a concrete demand signal, not evidence that every optional predicate is impossible in sqlc.
  • haykot's working notes describe parameterized bulk updates, nullable conditional filters and wrapping generated queries for transactions. The article's phrase “Limitations on conditional queries” explains a practical tradeoff. Its code is the author's example; I did not execute it or verify performance.

These are examples, not a five-tool ranking.

Recommendation by constraint

  • Small Postgres service, team reads SQL, predictable queries — sqlc + pgx + goose is my default starting point.
  • Many user-selected filters — compare Bun or GORM against a small handwritten pgx repository method before forcing every combination through sqlc.
  • Entity relationships dominate — ent, with generated versioned migrations reviewed in CI.
  • Existing GORM app — keep it and add reviewed migrations.
  • Need schema diffs and governance — evaluate Atlas against the precise objects and CI features required, including its billable usage.

A brief auth boundary

coreos/go-oidc is an OIDC client; goth integrates providers; Authboss provides application auth modules needing storage integration. Casdoor is a separate IAM server. These solve different identity jobs; this is orientation, not an auth review.

A prompt to give your agent

Inspect our Go module, database dialect and current schema owner. Compare sqlc+pgx, GORM, ent, Bun and pgx directly for one transactional write, one join and our actual optional-filter endpoint. Recommend a data layer and separately goose, golang-migrate or Atlas for migrations. Cite current versions and licences. Produce reviewable files on a branch and propose disposable-database checks for upgrade, failed upgrade and transaction rollback. Do not connect to production or apply schema changes.

Mistakes to check

  • Treating sqlc as a driver or migrator, or sharing one pgx connection across concurrent requests instead of a pool.
  • Letting model auto-migration and a versioned runner both own production schema changes.
  • Editing generated Go instead of the SQL/schema source; using unparameterized dynamic SQL.
  • Treating a down migration as a guarantee that deleted data can be restored.

Limits

No installs, queries, migrations or benchmarks were run. Official sources were checked 2026-10-20. One issue and one blog are thin evidence for GORM/ent/Bun and migration-tool comparisons; no success rate is implied. Auth versions/licences were not surveyed.

Started from a post by @kyleconroy, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# sqlc, GORM, ent, Bun or pgx for Go data access and migrations?
Summary: As of October 2026, choose sqlc with pgx and goose for SQL-owned Postgres queries and explicit migrations; GORM for convenient CRUD, ent for generated entity APIs, Bun for SQL-shaped builders, or pgx directly for manual control. Atlas adds schema planning, with edition and licence limits (checked 2026-10-20).
Copy for agent
get the whatworks thread sqlc-gorm-ent-bun-or-pgx-for-go-data-access-and-migrations and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread sqlc-gorm-ent-bun-or-pgx-for-go-data-access-and-migrations
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks