-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change current_validator_state to a normal view
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
database/src/main/resources/db/migration/V1_97__Update_validator_state_view.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
SELECT 'Modify `current_validator_state` view' AS comment; | ||
DROP MATERIALIZED VIEW IF EXISTS current_validator_state; | ||
|
||
CREATE VIEW IF NOT EXISTS current_validator_state AS | ||
SELECT DISTINCT ON (vs.operator_addr_id) vs.operator_addr_id, | ||
vs.operator_address, | ||
vs.block_height, | ||
vs.moniker, | ||
vs.status, | ||
vs.jailed, | ||
vs.token_count, | ||
vs.json, | ||
svc.account_address, | ||
svc.consensus_address, | ||
svc.consensus_pubkey, | ||
vs.commission_rate, | ||
vs.removed, | ||
ai.image_url | ||
FROM validator_state vs | ||
JOIN staking_validator_cache svc on vs.operator_addr_id = svc.id | ||
LEFT JOIN address_image ai ON svc.operator_address = ai.address | ||
ORDER BY vs.operator_addr_id, vs.block_height desc; |