Skip to content

deps: migrate lib/pq → pgx/v5 + go mod tidy (RUK-135) - #21

Merged
ruko1202 merged 1 commit into
mainfrom
feature/ruk-135
May 25, 2026
Merged

deps: migrate lib/pq → pgx/v5 + go mod tidy (RUK-135)#21
ruko1202 merged 1 commit into
mainfrom
feature/ruk-135

Conversation

@ruko1202

Copy link
Copy Markdown
Owner

TD-12: lib/pq has been in maintenance mode since 2020. Migrated the
runtime PG driver to github.com/jackc/pgx/v5/stdlib, which is the
active fork the ecosystem has rallied behind.

What changed:

  • pkg/goquestorage imports pgx/v5/stdlib (anonymous), so the "pgx"
    driver registers automatically for anyone using this package.
  • New PgxDriver = "pgx" and PgxV5Driver = "pgx/v5" constants for the
    two names pgx registers itself under.
  • PgDriver = "postgres" stays as a // Deprecated: alias. goquestorage
    no longer registers "postgres" — callers using this name must
    _ "github.com/lib/pq" in their own code. This is intentional:
    silently aliasing "postgres" to pgx inside the package would race
    with downstream binaries that also import lib/pq (panic on
    double-Register or silent type-mismatch in error handling,
    depending on init() order).
  • goque.NewStorage's switch accepts all three names.
  • internal/storages/pg/task/add_task.go handleError uses
    *pgconn.PgError + pgerrcode constants (UniqueViolation,
    InvalidTextRepresentation) instead of *pq.Error + Code.Name().
  • examples/service migrated to "pgx" — both config.yaml and the
    config.go default.
  • scripts/dbmodels/generate.go (dev-only jet code generator): jet's
    GenerateDSN is hard-coded to sql.Open("postgres", ...); rather
    than bring lib/pq back, we open via sqlx with "pgx" and pass jet
    the embedded *sql.DB through GenerateDB. MySQL and SQLite paths
    unchanged — jet self-imports their drivers.

TD-13 (go mod tidy): cron/v3 moved from indirect to direct (we use
it in periodic processors). pgerrcode added as a small direct dep.
lib/pq stays as indirect because go-jet/v2/postgres runtime package
pulls it transitively — out of our control without replacing jet.

Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com

TD-12: lib/pq has been in maintenance mode since 2020. Migrated the
runtime PG driver to github.com/jackc/pgx/v5/stdlib, which is the
active fork the ecosystem has rallied behind.

What changed:

- pkg/goquestorage imports pgx/v5/stdlib (anonymous), so the "pgx"
  driver registers automatically for anyone using this package.
- New PgxDriver = "pgx" and PgxV5Driver = "pgx/v5" constants for the
  two names pgx registers itself under.
- PgDriver = "postgres" stays as a // Deprecated: alias. goquestorage
  no longer registers "postgres" — callers using this name must
  `_ "github.com/lib/pq"` in their own code. This is intentional:
  silently aliasing "postgres" to pgx inside the package would race
  with downstream binaries that also import lib/pq (panic on
  double-Register or silent type-mismatch in error handling,
  depending on init() order).
- goque.NewStorage's switch accepts all three names.
- internal/storages/pg/task/add_task.go handleError uses
  *pgconn.PgError + pgerrcode constants (UniqueViolation,
  InvalidTextRepresentation) instead of *pq.Error + Code.Name().
- examples/service migrated to "pgx" — both config.yaml and the
  config.go default.
- scripts/dbmodels/generate.go (dev-only jet code generator): jet's
  GenerateDSN is hard-coded to sql.Open("postgres", ...); rather
  than bring lib/pq back, we open via sqlx with "pgx" and pass jet
  the embedded *sql.DB through GenerateDB. MySQL and SQLite paths
  unchanged — jet self-imports their drivers.

TD-13 (go mod tidy): cron/v3 moved from indirect to direct (we use
it in periodic processors). pgerrcode added as a small direct dep.
lib/pq stays as `indirect` because go-jet/v2/postgres runtime package
pulls it transitively — out of our control without replacing jet.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@ruko1202
ruko1202 merged commit 8d8d4a6 into main May 25, 2026
4 checks passed
@ruko1202
ruko1202 deleted the feature/ruk-135 branch May 25, 2026 12:59
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