Add basic postgres#324
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
|
@claude review |
There was a problem hiding this comment.
Pull request overview
Adds an initial PostgreSQL persistence backend alongside the existing SQLite store, and refactors the store tests so the same suite can run against either backend.
Changes:
- Introduces a new
persist/postgresstore implementation with schema initialization, encoding, transactions, chain updates, queries, host handling, metrics, and tests. - Refactors
internal/storetestfrom SQLite-specific tests into shared backend tests with SQLite/PostgreSQL factories. - Adds PostgreSQL CI coverage and pgx-related dependencies.
Reviewed changes
Copilot reviewed 39 out of 40 changed files in this pull request and generated 28 comments.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/main.yml |
Adds a PostgreSQL-backed CI test job. |
go.mod |
Adds PostgreSQL/pgx and test dependencies. |
go.sum |
Adds checksums for new dependencies. |
internal/storetest/addresses_test.go |
Moves address tests into shared storetest package. |
internal/storetest/consensus_test.go |
Adds shared consensus store tests. |
internal/storetest/contracts_test.go |
Moves contract tests into shared storetest package. |
internal/storetest/events_test.go |
Moves event tests into shared storetest package. |
internal/storetest/factory_postgres_test.go |
Adds PostgreSQL test-store factory. |
internal/storetest/factory_sqlite_test.go |
Adds SQLite test-store factory. |
internal/storetest/hosts_test.go |
Refactors host tests to use shared store helpers. |
internal/storetest/metrics_test.go |
Moves metrics tests into shared storetest package. |
internal/storetest/transactions_test.go |
Moves transaction tests into shared storetest package. |
internal/storetest/v2consensus_test.go |
Moves v2 consensus tests into shared storetest package. |
internal/storetest/v2contracts_test.go |
Moves v2 contract tests into shared storetest package. |
internal/storetest/v2transactions_test.go |
Moves v2 transaction tests into shared storetest package. |
persist/sqlite/consensus_test.go |
Removes SQLite-local consensus tests after moving them to storetest. |
persist/sqlite/testing.go |
Adds SQLite host seeding helper for shared tests. |
persist/postgres/addresses.go |
Adds PostgreSQL address/event/balance queries. |
persist/postgres/blocks.go |
Adds PostgreSQL block and tip queries. |
persist/postgres/consensus.go |
Adds PostgreSQL chain-state update and host scan logic. |
persist/postgres/contracts.go |
Adds PostgreSQL v1 contract queries. |
persist/postgres/encoding.go |
Adds PostgreSQL value encoding/decoding helpers. |
persist/postgres/events.go |
Adds PostgreSQL event queries and unconfirmed event annotation. |
persist/postgres/hosts.go |
Adds PostgreSQL host scan and host query support. |
persist/postgres/init.go |
Adds PostgreSQL schema initialization and migration handling. |
persist/postgres/init.sql |
Adds initial PostgreSQL schema. |
persist/postgres/merkle.go |
Adds PostgreSQL Merkle proof lookup. |
persist/postgres/metrics.go |
Adds PostgreSQL network/host/difficulty metrics. |
persist/postgres/migrations.go |
Adds PostgreSQL migration list scaffold. |
persist/postgres/revert.go |
Adds PostgreSQL chain revert deletion logic. |
persist/postgres/search.go |
Adds PostgreSQL search implementation. |
persist/postgres/sql.go |
Adds pgx transaction/statement wrappers. |
persist/postgres/store.go |
Adds PostgreSQL store constructor, connection handling, and transactions. |
persist/postgres/store_test.go |
Adds PostgreSQL database creation test. |
persist/postgres/testing.go |
Adds PostgreSQL test helpers. |
persist/postgres/transactions.go |
Adds PostgreSQL v1 transaction queries. |
persist/postgres/v2consensus.go |
Adds PostgreSQL v2 chain-state persistence. |
persist/postgres/v2contracts.go |
Adds PostgreSQL v2 contract queries. |
persist/postgres/v2transactions.go |
Adds PostgreSQL v2 transaction queries. |
Comments suppressed due to low confidence (1)
persist/postgres/v2transactions.go:285
- These errors are emitted while querying/scanning siafund inputs, but they say “siacoin inputs”. That will make debugging PostgreSQL failures harder because the reported component is wrong.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
That Claude review was hardly worth $15! |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
b523462 to
0a5aaba
Compare
0a5aaba to
13c5498
Compare
There was a problem hiding this comment.
An organization admin can view or raise the cap at claude.ai/admin-settings/claude-code. The cap resets at the start of the next billing period.
Once the cap resets or is raised, reopen this pull request to trigger a review.
e703d4e to
a8357c0
Compare
39bb556 to
913753b
Compare
913753b to
11cc994
Compare
c2c0119 to
6bf0bbb
Compare
9db643d to
72e8370
Compare
There was a problem hiding this comment.
An organization admin can view or raise the cap at claude.ai/admin-settings/claude-code. The cap resets at the start of the next billing period.
Once the cap resets or is raised, reopen this pull request to trigger a review.
There was a problem hiding this comment.
An organization admin can view or raise the cap at claude.ai/admin-settings/claude-code. The cap resets at the start of the next billing period.
Once the cap resets or is raised, reopen this pull request to trigger a review.
Re: #321
This is meant to be a very literal translation of the sqlite with a minimum amount of changes for things that broke. I will do postgres specific optimizations in a followup PR.
To reviewers, use this command to view the difference between the sqlite files and the postgres files: