HafSQL v2.7.0

in HiveDevs • yesterday

HafSQL v2.7.0: changes for public database users

Removed tables

  • hafsql.rc_delegations_table is gone. Use the hafsql.rc_delegations view, which now reads from balance_tracker.
  • hafsql.proposal_approvals_table is gone. Use the hafsql.proposal_approvals view, which now reads from hafbe.

Removed columns from hafsql.accounts_table

reward_hive_balance, reward_hbd_balance, reward_vests_balance, to_withdraw, vesting_withdraw_rate, withdrawn and proxy are gone. The hafsql.accounts view still has all of them under the same names. They now come from balance_tracker / hafbe. If you queried accounts_table directly, switch to the view.

View columns that changed (same names, different values or types)

View.columnBeforeNow
delegations.vestsraw ×1,000,000VESTS, numeric(27,6)
accounts.incoming_vests / outgoing_vestsraw ×1,000,000VESTS. *_hp columns unchanged
accounts.to_withdrawremaining amount, dropped after each payouttotal power-down amount (as in hived)
accounts.vesting_withdraw_rateto_withdraw / 13rounded up, as hived does since HF21
accounts.next_vesting_withdrawaldrifted 3s per weekly payoutexact. NULL when no power down is active
rc_delegations.rctextnumeric
rc_delegations.timestamplast sync time of the rowblock time of the delegation op
comments.net_rsharessum of absolute rsharessigned sum (downvotes subtract)
comments.abs_rsharesn/anew column: sum of absolute rshares
comments.total_rshares / net_rshareschanged votes counted twiceonly each voter's latest vote counts
operation_account_update*_table.json_metadata / posting_json_metadata{} when the op left it emptyNULL (empty means "unchanged" on chain)

Behavior changes

  • Comments deleted and then re-posted at the same permlink are now a new row with a new id, the same as hivemind. Before, they stayed marked as deleted.
  • Weekly market buckets now run Monday to Sunday. Before, Sunday trades landed in the next week. Existing buckets are rebuilt.
  • hafsql.get_timestamp, hafsql.id_from_timestamp and comments.cashout_time / last_payout now give correct results when your session timezone isn't UTC.
  • hafsql.get_timestamp now also accepts a block number (int4).
  • hafd.operation_id_to_type_id was removed from the docs.

Fixes (no query changes needed)

  • Reblog permlinks were wrong.
  • Account metadata was wiped by updates with empty metadata.
  • Comment titles were blanked by edits with an empty title.
  • get_balance(account, block) and balances_history were slow.
Sort:  

Making net_rshares a signed sum and counting only each voter's latest vote is a big fix for anyone analyzing curation data. Does it recalculate older comments too, or only rows synced after the upgrade?

 yesterday  

All the data is retroactively fixed.

Swapping the raw times-a-million vests columns for proper numeric values is a change everyone querying the views will quietly appreciate.