Skip to content

Commit 8928552

Browse files
committed
Handle NULLs in hourly_statistics backfill
Use COALESCE for total_fee and total_gas_used when backfilling indexer.hourly_statistics_agg from indexer.hourly_statistics to avoid inserting NULLs. This ensures missing values are treated as 0 during the migration (packages/graphql/database/migrations/046_replace_hourly_statistics_mv_with_agg_table.sql) and preserves the existing ON CONFLICT update behavior.
1 parent ca7dab1 commit 8928552

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/graphql/database/migrations/046_replace_hourly_statistics_mv_with_agg_table.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ GRANT SELECT ON indexer.hourly_statistics_agg TO explorer_ro;
2424

2525
-- Backfill from existing MV if it has data
2626
INSERT INTO indexer.hourly_statistics_agg (hour, total_fee, total_gas_used)
27-
SELECT hour, total_fee, total_gas_used
27+
SELECT hour, COALESCE(total_fee, 0), COALESCE(total_gas_used, 0)
2828
FROM indexer.hourly_statistics
2929
ON CONFLICT (hour) DO UPDATE
3030
SET total_fee = excluded.total_fee,

0 commit comments

Comments
 (0)