Skip to content

chore(deps): migrate postgres driver from pgx v4 to v5 - #1817

Open
AmanGIT07 wants to merge 1 commit into
chore/upgrade-go-depsfrom
chore/upgrade-pgx-v5
Open

chore(deps): migrate postgres driver from pgx v4 to v5#1817
AmanGIT07 wants to merge 1 commit into
chore/upgrade-go-depsfrom
chore/upgrade-pgx-v5

Conversation

@AmanGIT07

Copy link
Copy Markdown
Contributor

Summary

Migrates the Postgres driver from pgx v4 to pgx v5. The v4 line is in maintenance mode; v5 absorbed the standalone pgconn, pgproto3 and pgtype modules. Resolves the two govulncheck findings that have no fix on the v4 line (GO-2026-5004, GO-2026-4518). GO-2026-5617 is no longer reported as reachable once the v4 module family leaves the dependency graph.

Changes

  • Swap github.com/jackc/pgx/v4github.com/jackc/pgx/v5: driver registration (stdlib) in cmd/serve.go and internal/store/postgres, pgx.ParseConfig in cmd/serve.go, pgx.Connect readiness probe in test/e2e/testbench
  • Swap standalone github.com/jackc/pgconngithub.com/jackc/pgx/v5/pgconn for Postgres error inspection (postgres.go, billing_transactions_repository.go)
  • go.mod: pgx/v5 v5.10.0 in; pgx/v4, pgconn, pgproto3/v2, pgtype, chunkreader/v2, pgio out
  • Add TestCheckPostgresError covering every error-code translation in checkPostgresError, including wrapped errors and passthrough cases
  • Add TestBillingTransactionRepository covering CreateEntry and replaying the same transaction (ErrAlreadyApplied)

Technical Details

No query or repository logic changes — the store layer talks to database/sql via goqu/sqlx, and the registered driver name stays pgx, so configuration is unchanged. Error matching relies on the driver returning v5's *pgconn.PgError; the new repository test exercises this against a real Postgres, including the constraint-name check in the billing replay path.

Base is chore/upgrade-go-deps (#1813); this PR retargets to main automatically when that merges.

Test Plan

  • go build ./... and go vet ./... pass
  • make lint passes (0 issues)
  • make test passes (race detector, -count 2)
  • make e2e-test passes against live Postgres + SpiceDB containers
  • govulncheck ./... reports no findings from pgx modules

SQL Safety (if your PR touches *_repository.go or goqu.*)

  • Values flow through ? placeholders, goqu.Ex{}, or goqu.Record{} — never fmt.Sprintf or + building a query that gets executed.
  • ToSQL() callers capture and forward params (query, params, err := stmt.ToSQL(); db.…Context(ctx, …, query, params...)). Never query, _, err := ….
  • No ? placeholders inside single-quoted SQL literals in goqu.L (use make_interval(hours => ?)-style functions instead).
  • Any //nolint:forbidigo or // #nosec G20x annotation has a one-line justification on the same line that a reviewer can verify.

🤖 Generated with Claude Code

Swaps pgx/v4 and the standalone pgconn module for pgx/v5, which
absorbed them. Repository code is unchanged; error matching now uses
the v5 pgconn error type. Adds tests for the postgres error
translation and the billing transaction replay path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment Jul 29, 2026 8:54am

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 037bb714-ac94-4880-a9d6-3fcabddebb68

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/store/postgres/billing_transactions_repository_test.go (1)

94-110: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert translated diagnostic details too.

The table cases populate only Code and assert ErrorIs. A regression that drops PgError.Detail or PgError.Message from the translated error would still pass. Add representative detail/message values and assert they are preserved.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4f0af9ba-4f56-4bb4-88dd-e58a9021c47e

📥 Commits

Reviewing files that changed from the base of the PR and between 686bd6d and 41ecc3b.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (7)
  • cmd/serve.go
  • go.mod
  • internal/store/postgres/billing_transactions_repository.go
  • internal/store/postgres/billing_transactions_repository_pg_test.go
  • internal/store/postgres/billing_transactions_repository_test.go
  • internal/store/postgres/postgres.go
  • test/e2e/testbench/postgres.go

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.

1 participant