Sui indexer is an off-fullnode service to serve data from Sui protocol, including both data directly generated from chain and derivative data.
- install local Postgres server
- install Diesel CLI, you can follow the Diesel Getting Started guide up to the Write Rust section
- [optional but handy] Postgres client like Postico, for local check, query execution etc.
- DB setup
# DB setup, run the following commands from the /sui-indexer folder
# .env file under /sui-indexer is required for diesel cmds
# in .env file, DATABASE_URL should point to your local PG server
# an example is:
# DATABASE_URL="postgres://postgres:postgres@localhost/gegao"
diesel setup
# and then run
diesel migration run
- checkout the latest devnet commit by running commands below, otherwise API version mismatch could cause errors
git fetch upstream devnet
git reset --hard upstream/devnet
- Go to
sui/crates/sui-indexer
and run the following command:
# DATABASE_URL should be the same value as above
cargo run --bin sui-indexer -- --db-url "<DATABASE_URL>" --rpc-client-url "https://fullnode.devnet.sui.io:443"
- Run
diesel migration revert
under/sui-indexer
until no more tables are deleted; - Also delete
__diesel_schema_migrations
, you can do this via Postico client