Skip to content

Add PostgreSQL storage driver alongside the existing redb file driver - #6

Closed
pandres95 wants to merge 14 commits into
devfrom
feat/postgres-storage-driver
Closed

Add PostgreSQL storage driver alongside the existing redb file driver#6
pandres95 wants to merge 14 commits into
devfrom
feat/postgres-storage-driver

Conversation

@pandres95

@pandres95 pandres95 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Introduces an async Storage trait so account/deposit/sweep bookkeeping can be backed by different drivers.
  • Adds a new PostgresStorage driver (via sqlx) selected automatically when DATABASE_URL starts with postgres:// or postgresql://; any other value keeps using the existing RedbStorage file driver.
  • Schema is created idempotently on connect for both drivers, so no manual migration step is required to start using Postgres.
  • Updates .env.example and the README to document both URL forms.

Test plan

  • cargo check --all-targets
  • cargo test (17 passed, redb driver path)
  • Manual smoke test against a live PostgreSQL instance (Docker postgres:16-alpine), exercising every Storage method end-to-end: schema bootstrap, account register/lookup/upsert, native deposit record + dedup + sweep-mark, block tracking, token metadata cache, ERC20 deposit record + bulk sweep-mark + sweep tx hash, sweep-failure tracking, zero-balance retry tracking. Also confirmed data persists correctly across a fresh connection (dedup correctly rejected a deposit already committed by a prior run).

S0c5 and others added 14 commits December 26, 2025 15:31
Splits the storage layer behind an async Storage trait so the backend can
be chosen at runtime from DATABASE_URL: a postgres:// / postgresql:// URL
selects the new sqlx-based PostgresStorage, anything else keeps using the
existing RedbStorage file driver. Schema is created idempotently on
connect for both drivers.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@S0c5

S0c5 commented Jul 17, 2026

Copy link
Copy Markdown
Member

Superseded by #12, which reworks this against the current single-writer-actor + priority-lane + WAL-checkpoint codebase (this PR was 27 commits behind, built against the old redb-based dev branch, and used an async sqlx rewrite that we've since decided against in favor of keeping the sync Db API surface unchanged).

@S0c5 S0c5 closed this Jul 17, 2026
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.

2 participants