Add derived trades table schema#2587
Conversation
📝 WalkthroughWalkthroughThis PR introduces the ChangesDerived Trades Table Introduction
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
How to use the Graphite Merge QueueAdd the label Raindex-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/settings/src/local_db_manifest.rs`:
- Line 12: Tests in this file still assert and use the old db-schema-version (3)
after updating the constant DB_SCHEMA_VERSION to 4, causing
parse_manifest_header/parse_manifest_doc to fail; update all fixtures and
assertions to use the new schema version or, better, make fixtures driven by the
DB_SCHEMA_VERSION constant (e.g., use the constant when constructing test
manifest headers and replace hard-coded `db-schema-version: 3` and `sv == 3`
checks with DB_SCHEMA_VERSION or a helper that emits the current
DB_SCHEMA_VERSION) so parse_manifest_header/parse_manifest_doc and sv assertions
stay in sync.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: fe951c46-c297-4b06-911f-ef16e953f9f4
📒 Files selected for processing (5)
crates/common/src/local_db/query/clear_raindex_data/query.sqlcrates/common/src/local_db/query/clear_tables/query.sqlcrates/common/src/local_db/query/create_tables/mod.rscrates/common/src/local_db/query/create_tables/query.sqlcrates/settings/src/local_db_manifest.rs
|
|
||
| pub const MANIFEST_VERSION: u32 = 1; | ||
| pub const DB_SCHEMA_VERSION: u32 = 3; | ||
| pub const DB_SCHEMA_VERSION: u32 = 4; |
There was a problem hiding this comment.
Update manifest test fixtures to schema version 4.
After Line 12 bumped DB_SCHEMA_VERSION to 4, tests in this file still use db-schema-version: 3 (and some assert sv == 3), which will now fail through parse_manifest_header/parse_manifest_doc.
Suggested fix pattern
- db-schema-version: 3
+ db-schema-version: 4Or better, avoid future churn by templating fixtures with DB_SCHEMA_VERSION in helper builders.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/settings/src/local_db_manifest.rs` at line 12, Tests in this file
still assert and use the old db-schema-version (3) after updating the constant
DB_SCHEMA_VERSION to 4, causing parse_manifest_header/parse_manifest_doc to
fail; update all fixtures and assertions to use the new schema version or,
better, make fixtures driven by the DB_SCHEMA_VERSION constant (e.g., use the
constant when constructing test manifest headers and replace hard-coded
`db-schema-version: 3` and `sv == 3` checks with DB_SCHEMA_VERSION or a helper
that emits the current DB_SCHEMA_VERSION) so
parse_manifest_header/parse_manifest_doc and sv assertions stay in sync.

Chained PRs
Stack order: #2587 -> #2588 -> #2589 -> #2590
Motivation
Trade-list reads need a persistent local DB read model so the API and SDK do not reconstruct trades from raw event tables on every request. This first PR establishes the schema surface for that read model.
Solution
derived_tradestable with a stable primary key and token, owner, taker, order-hash, and transaction indexes.derived_tradesin clear/reset paths.Checks
COMMIT_SHA=local nix develop -c cargo test -p raindex_common local_db::query --libCOMMIT_SHA=local nix develop -c cargo test -p raindex_common local_db::pipeline::adapters::apply --libCOMMIT_SHA=local nix develop -c cargo test -p raindex_common local_db::export --libCOMMIT_SHA=local nix develop -c cargo test -p raindex_common raindex_client::trades --libSummary by CodeRabbit