## Graphman Commands
- [Info](#info)
- [Remove](#remove)
- [Unassign](#unassign)
- [Unused Record](#unused-record)
- [Unused Remove](#unused-remove)
- [Drop](#drop)
- [Chain Check Blocks](#check-blocks)
- [Chain Call Cache Remove](#chain-call-cache-remove)
# ⌘ Info
### SYNOPSIS
Prints the details of a deployment
The deployment can be specified as either a subgraph name, an IPFS hash `Qm..`, or the database
namespace `sgdNNN`. Since the same IPFS hash can be deployed in multiple shards, it is possible to
specify the shard by adding `:shard` to the IPFS hash.
USAGE:
graphman --config info [OPTIONS]
ARGS:
The deployment (see above)
OPTIONS:
-c, --current
List only current version
-h, --help
Print help information
-p, --pending
List only pending versions
-s, --status
Include status information
-u, --used
List only used (current and pending) versions
### DESCRIPTION
The `info` command fetches details for a given deployment from the database.
By default, it shows the following attributes for the deployment:
- **name**
- **status** *(`pending` or `current`)*
- **id** *(the `Qm...` identifier for the deployment's subgraph)*
- **namespace** *(The database schema which contains that deployment data tables)*
- **shard**
- **active** *(If there are multiple entries for the same subgraph, only one of them will be active. That's the one we use for querying)*
- **chain**
- **graph node id**
### OPTIONS
If the `--status` option is enabled, extra attributes are also returned:
- **synced*** *(Whether or not the subgraph has synced all the way to the current chain head)*
- **health** *(Can be either `healthy`, `unhealthy` (syncing with errors) or `failed`)*
- **latest indexed block**
- **current chain head block**
### EXAMPLES
Describe a deployment by its name:
graphman --config config.toml info subgraph-name
Describe a deployment by its hash:
graphman --config config.toml info QmfWRZCjT8pri4Amey3e3mb2Bga75Vuh2fPYyNVnmPYL66
Describe a deployment with extra info:
graphman --config config.toml info QmfWRZCjT8pri4Amey3e3mb2Bga75Vuh2fPYyNVnmPYL66 --status
# ⌘ Remove
### SYNOPSIS
Remove a named subgraph
USAGE:
graphman --config remove
ARGS:
The name of the subgraph to remove
OPTIONS:
-h, --help Print help information
### DESCRIPTION
Removes the association between a subgraph name and a deployment.
No indexed data is lost as a result of this command.
It is used mostly for stopping query traffic based on the subgraph's name, and to release that name for
another deployment to use.
### EXAMPLES
Remove a named subgraph:
graphman --config config.toml remove subgraph-name
# ⌘ Unassign
#### SYNOPSIS
Unassign a deployment
USAGE:
graphman --config unassign
ARGS:
The deployment (see `help info`)
OPTIONS:
-h, --help Print help information
#### DESCRIPTION
Makes `graph-node` stop indexing a deployment permanently.
No indexed data is lost as a result of this command.
Refer to the [Maintenance Documentation](https://github.com/graphprotocol/graph-node/blob/master/docs/maintenance.md#modifying-assignments) for more details about how Graph Node manages its deployment
assignments.
#### EXAMPLES
Unassign a deployment by its name:
graphman --config config.toml unassign subgraph-name
Unassign a deployment by its hash:
graphman --config config.toml unassign QmfWRZCjT8pri4Amey3e3mb2Bga75Vuh2fPYyNVnmPYL66
# ⌘ Unused Record
### SYNOPSIS
graphman-unused-record
Update and record currently unused deployments
USAGE:
graphman unused record
OPTIONS:
-h, --help Print help information
### DESCRIPTION
Inspects every shard for unused deployments and registers them in the `unused_deployments` table in the
primary shard.
No indexed data is lost as a result of this command.
This sub-command is used as previous step towards removing all data from unused subgraphs, followed by
`graphman unused remove`.
A deployment is unused if it fulfills all of these criteria:
1. It is not assigned to a node.
2. It is either not marked as active or is neither the current or pending version of a subgraph.
3. It is not the source of a currently running copy operation
### EXAMPLES
To record all unused deployments:
graphman --config config.toml unused record
# ⌘ Unused Remove
### SYNOPSIS
Remove deployments that were marked as unused with `record`.
Deployments are removed in descending order of number of entities, i.e., smaller deployments are
removed before larger ones
USAGE:
graphman unused remove [OPTIONS]
OPTIONS:
-c, --count
How many unused deployments to remove (default: all)
-d, --deployment
Remove a specific deployment
-h, --help
Print help information
-o, --older
Remove unused deployments that were recorded at least this many minutes ago
### DESCRIPTION
Removes from database all indexed data from deployments previously marked as unused by the `graphman unused
record` command.
This operation is irreversible.
### EXAMPLES
Remove all unused deployments
graphman --config config.toml unused remove
Remove all unused deployments older than 12 hours (720 minutes)
graphman --config config.toml unused remove --older 720
Remove a specific unused deployment
graphman --config config.toml unused remove --deployment QmfWRZCjT8pri4Amey3e3mb2Bga75Vuh2fPYyNVnmPYL66
# ⌘ Drop
### SYNOPSIS
Delete a deployment and all its indexed data
The deployment can be specified as either a subgraph name, an IPFS hash `Qm..`, or the database
namespace `sgdNNN`. Since the same IPFS hash can be deployed in multiple shards, it is possible to
specify the shard by adding `:shard` to the IPFS hash.
USAGE:
graphman --config drop [OPTIONS]
ARGS:
The deployment identifier
OPTIONS:
-c, --current
Search only for current versions
-f, --force
Skip confirmation prompt
-h, --help
Print help information
-p, --pending
Search only for pending versions
-u, --used
Search only for used (current and pending) versions
### DESCRIPTION
Stops, unassigns and remove all data from deployments matching the search term.
This operation is irreversible.
This command is a combination of other graphman commands applied in sequence:
1. `graphman info `
2. `graphman unassign `
3. `graphman remove `
4. `graphman unused record`
5. `graphman unused remove `
### EXAMPLES
Stop, unassign and delete all indexed data from a specific deployment by its deployment id
graphman --config config.toml drop QmfWRZCjT8pri4Amey3e3mb2Bga75Vuh2fPYyNVnmPYL66
Stop, unassign and delete all indexed data from a specific deployment by its subgraph name
graphman --config config.toml drop author/subgraph-name
# ⌘ Check Blocks
### SYNOPSIS
Compares cached blocks with fresh ones and clears the block cache when they differ
USAGE:
graphman --config chain check-blocks
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
ARGS:
Chain name (must be an existing chain, see 'chain list')
SUBCOMMANDS:
by-hash The number of the target block
by-number The hash of the target block
by-range A block number range, inclusive on both ends
### DESCRIPTION
The `check-blocks` command compares cached blocks with blocks from a JSON RPC provider and removes any blocks
from the cache that differ from the ones retrieved from the provider.
Sometimes JSON RPC providers send invalid block data to Graph Node. The `graphman chain check-blocks` command
is useful to diagnose the integrity of cached blocks and eventually fix them.
### OPTIONS
Blocks can be selected by different methods. The `check-blocks` command lets you use the block hash, a single
number or a number range to refer to which blocks it should verify:
#### `by-hash`
graphman --config chain check-blocks by-hash
#### `by-number`
graphman --config chain check-blocks by-number [--delete-duplicates]
#### `by-range`
graphman --config chain check-blocks by-range [-f|--from ] [-t|--to ] [--delete-duplicates]
The `by-range` method lets you scan for numeric block ranges and offers the `--from` and `--to` options for
you to define the search bounds. If one of those options is omitted, `graphman` will consider an open bound
and will scan all blocks up to or after that number.
Over time, it can happen that a JSON RPC provider offers different blocks for the same block number. In those
cases, `graphman` will not decide which block hash is the correct one and will abort the operation. Because of
this, the `by-number` and `by-range` methods also provide a `--delete-duplicates` flag, which orients
`graphman` to delete all duplicated blocks for the given number and resume its operation.
### EXAMPLES
Inspect a single Ethereum Mainnet block by hash:
graphman --config config.toml chain check-blocks mainnet by-hash 0xd56a9f64c7e696cfeb337791a7f4a9e81841aaf4fcad69f9bf2b2e50ad72b972
Inspect a block using its number:
graphman --config config.toml chain check-blocks mainnet by-number 15626962
Inspect a block range, deleting any duplicated blocks:
graphman --config config.toml chain check-blocks mainnet by-range --from 15626900 --to 15626962 --delete-duplicates
Inspect all blocks after block `13000000`:
graphman --config config.toml chain check-blocks mainnet by-range --from 13000000
# ⌘ Chain Call Cache Remove
### SYNOPSIS
Remove the call cache of the specified chain.
Either remove entries in the range `--from` and `--to`, remove stale contracts which have not been accessed for a specified duration `--ttl_days`, or remove the entire cache with `--remove-entire-cache`. Removing the entire cache can reduce indexing performance significantly and should generally be avoided.
Usage: graphman chain call-cache remove [OPTIONS]
Options:
--remove-entire-cache
Remove the entire cache
--ttl-days
Remove stale contracts based on call_meta table
--ttl-max-contracts
Limit the number of contracts to consider for stale contract removal
-f, --from
Starting block number
-t, --to
Ending block number
-h, --help
Print help (see a summary with '-h')
### DESCRIPTION
Remove the call cache of a specified chain.
### OPTIONS
The `from` and `to` options are used to decide the block range of the call cache that needs to be removed.
#### `from`
The `from` option is used to specify the starting block number of the block range. In the absence of `from` option,
the first block number will be used as the starting block number.
#### `to`
The `to` option is used to specify the ending block number of the block range. In the absence of `to` option,
the last block number will be used as the ending block number.
#### `--remove-entire-cache`
The `--remove-entire-cache` option is used to remove the entire call cache of the specified chain.
#### `--ttl-days `
The `--ttl-days` option is used to remove stale contracts based on the `call_meta.accessed_at` field. For example, if `--ttl-days` is set to 7, all calls to a contract that has not been accessed in the last 7 days will be removed from the call cache.
#### `--ttl-max-contracts `
The `--ttl-max-contracts` option is used to limit the maximum number of contracts to be removed when using the `--ttl-days` option. For example, if `--ttl-max-contracts` is set to 100, at most 100 contracts will be removed from the call cache even if more contracts meet the TTL criteria.
### EXAMPLES
Remove the call cache for all blocks numbered from 10 to 20:
graphman --config config.toml chain call-cache ethereum remove --from 10 --to 20
Remove all the call cache of the specified chain:
graphman --config config.toml chain call-cache ethereum remove --remove-entire-cache
Remove stale contracts from the call cache that have not been accessed in the last 7 days:
graphman --config config.toml chain call-cache ethereum remove --ttl-days 7
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:
graphman --config config.toml chain call-cache ethereum remove --ttl-days 7 --ttl-max-contracts 100