From 33e5cc2b48c447d705fa74e7d70f17aff2bfdd95 Mon Sep 17 00:00:00 2001 From: Jason D Date: Mon, 30 Dec 2024 17:12:23 -0700 Subject: [PATCH] change current_validator_state to a normal view --- .../V1_97__Update_validator_state_view.sql | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 database/src/main/resources/db/migration/V1_97__Update_validator_state_view.sql diff --git a/database/src/main/resources/db/migration/V1_97__Update_validator_state_view.sql b/database/src/main/resources/db/migration/V1_97__Update_validator_state_view.sql new file mode 100644 index 00000000..95f6eae5 --- /dev/null +++ b/database/src/main/resources/db/migration/V1_97__Update_validator_state_view.sql @@ -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;