Skip to content

fix(db): connect to postgres via gorm's bundled pgx driver - #87

Merged
Savid merged 1 commit into
masterfrom
fix/postgres-driver
Jun 10, 2026
Merged

Savid merged 1 commit into
masterfrom
fix/postgres-driver

Conversation

@Savid

@Savid Savid commented Jun 10, 2026

Copy link
Copy Markdown
Member

Problem

The mainnet deployment crashes at startup:

level=fatal msg="failed to create indexer: sql: unknown driver \"postgres\" (forgotten import?)"

The skeleton refactor (#85) deleted the old main.go, which carried _ "github.com/lib/pq" — the blank import that registered the postgres driver with database/sql — and dropped lib/pq from go.mod. But internal/db/indexer.go still set postgres.Config.DriverName: "postgres", which makes the gorm postgres dialect call sql.Open("postgres", ...) instead of using its bundled pgx driver. No registered driver → fatal at boot.

It slipped through because every local/dev/CI path (make run with config.yaml, the test suite) uses the sqlite driver — the postgres branch of NewIndexer only executes in real deployments.

Fix

Leave Config.DriverName empty so the gorm dialect connects through its bundled pgx driver — no database/sql registration needed, no resurrecting lib/pq.

Verification

  • Booted the patched binary against a real postgres:16 container: indexer starts, frame_metadata + frame_metadata_labels auto-migrate, retention/maintenance queries run.
  • make lint (0 issues), go test -race ./... green.

After this and #86 land, re-point the v1.0.0 tag (or cut a new tag) so the release builds with both fixes.

🤖 Generated with Claude Code

The skeleton refactor dropped the lib/pq blank import (old main.go)
that registered the "postgres" database/sql driver, but the indexer
still set postgres.Config.DriverName — which makes gorm call
sql.Open("postgres", ...) and crash at startup with `sql: unknown
driver "postgres"`. Leave DriverName empty so the gorm postgres
dialect opens the connection through its bundled pgx driver.

Verified against a real postgres 16 container: indexer boots, both
frame_metadata tables auto-migrate, maintenance queries run.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Savid
Savid merged commit 4690420 into master Jun 10, 2026
5 checks passed
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