Skip to content

Commit

Permalink
sql: Create init script with some conversions for eth/gwei
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedmansour committed Oct 27, 2021
1 parent 396544d commit b66d375
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions migration/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
create table block_stats (
number INTEGER PRIMARY KEY,
timestamp INTEGER,
base_fee NUMERIC(256),
burned NUMERIC(256),
gas_target INTEGER,
gas_used INTEGER,
gas_used_percentage INTEGER,
priority_fee NUMERIC(256),
rewards NUMERIC(256),
tips NUMERIC(256),
transactions INTEGER,
type2_transactions INTEGER
);

CREATE FUNCTION eth(numeric) RETURNS numeric
AS 'select $1 / 1000000000000000000;'
LANGUAGE SQL
IMMUTABLE
RETURNS NULL ON NULL INPUT;

CREATE FUNCTION gwei(numeric) RETURNS numeric
AS 'select $1 / 1000000000;'
LANGUAGE SQL
IMMUTABLE
RETURNS NULL ON NULL INPUT;

0 comments on commit b66d375

Please sign in to comment.