Repository navigation
fix(db): connect to postgres via gorm's bundled pgx driver - #87
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The mainnet deployment crashes at startup:
The skeleton refactor (#85) deleted the old
main.go, which carried_ "github.com/lib/pq"— the blank import that registered thepostgresdriver withdatabase/sql— and droppedlib/pqfromgo.mod. Butinternal/db/indexer.gostill setpostgres.Config.DriverName: "postgres", which makes the gorm postgres dialect callsql.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 runwithconfig.yaml, the test suite) uses the sqlite driver — the postgres branch ofNewIndexeronly executes in real deployments.Fix
Leave
Config.DriverNameempty so the gorm dialect connects through its bundled pgx driver — nodatabase/sqlregistration needed, no resurrectinglib/pq.Verification
postgres:16container: indexer starts,frame_metadata+frame_metadata_labelsauto-migrate, retention/maintenance queries run.make lint(0 issues),go test -race ./...green.After this and #86 land, re-point the
v1.0.0tag (or cut a new tag) so the release builds with both fixes.🤖 Generated with Claude Code