Skip to content

Commit df3a38b

Browse files
docs: Document graphman chain rebuild-storage command
Adds synopsis, description, constraints, and examples for the new chain rebuild-storage subcommand.
1 parent b10906f commit df3a38b

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

docs/graphman.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- [Drop](#drop)
99
- [Chain Check Blocks](#check-blocks)
1010
- [Chain Call Cache Remove](#chain-call-cache-remove)
11+
- [Chain Rebuild Storage](#chain-rebuild-storage)
1112

1213
<a id="info"></a>
1314
# ⌘ Info
@@ -439,3 +440,69 @@ Remove stale contracts from the call cache that have not been accessed in the la
439440
Remove stale contracts from the call cache that have not been accessed in the last 7 days, limiting the removal to a maximum of 100 contracts:
440441
graphman --config config.toml chain call-cache ethereum remove --ttl-days 7 --ttl-max-contracts 100
441442

443+
<a id="chain-rebuild-storage"></a>
444+
# ⌘ Chain Rebuild Storage
445+
446+
### SYNOPSIS
447+
448+
Rebuild a chain's storage schema and reset head metadata
449+
450+
If the storage schema is missing, rebuilds it silently.
451+
If the storage already exists, prompts for confirmation before
452+
dropping and rebuilding it (use --force to skip the prompt).
453+
454+
USAGE:
455+
graphman --config <CONFIG> chain rebuild-storage [OPTIONS] <CHAIN_NAME>
456+
457+
ARGS:
458+
<CHAIN_NAME> Chain name (must be an existing chain, see 'chain list')
459+
460+
OPTIONS:
461+
-f, --force Skip confirmation prompt when storage already exists
462+
-h, --help Print help information
463+
464+
### DESCRIPTION
465+
466+
The `chain rebuild-storage` command recovers from a situation where a chain's storage schema
467+
(e.g. `chain42`) has been dropped or corrupted on the shard but the chain's metadata in
468+
`public.chains` still exists. This can happen after manual database operations or partial failures.
469+
470+
The command behaves differently depending on the state of the storage:
471+
472+
**Storage missing** (non-destructive): the command silently rebuilds the schema and resets
473+
head metadata. No confirmation is required.
474+
475+
**Storage exists** (destructive): the command prompts for confirmation before dropping the
476+
existing schema and rebuilding it from scratch. Use `--force` to skip the prompt.
477+
478+
In both cases, the command performs the following steps in a single transaction:
479+
480+
1. Drops the existing storage schema if present (`DROP SCHEMA IF EXISTS ... CASCADE`).
481+
2. Upserts the chain's row in `ethereum_networks` on the shard: inserts if missing, or repairs
482+
identity metadata (`namespace`, `net_version`, `genesis_block_hash`) and resets head tracking
483+
columns (`head_block_hash`, `head_block_number`, `head_block_cursor`) to `NULL` if the row exists.
484+
3. Rebuilds the storage schema with empty `blocks`, `call_cache`, and `call_meta` tables.
485+
486+
After this, graph-node will treat the chain as freshly added and begin syncing from scratch.
487+
488+
The `public.chains` metadata row is never modified by this command.
489+
490+
### CONSTRAINTS
491+
492+
- The chain must already exist in `public.chains`. This command does not create new chains.
493+
- Chains using shared storage (`public`) are not supported.
494+
495+
### EXAMPLES
496+
497+
Rebuild missing storage for a chain:
498+
499+
graphman --config config.toml chain rebuild-storage mainnet
500+
501+
Force-rebuild existing storage (skips confirmation):
502+
503+
graphman --config config.toml chain rebuild-storage mainnet --force
504+
505+
Check what chains are available:
506+
507+
graphman --config config.toml chain list
508+

0 commit comments

Comments
 (0)