From b66d3758247568481d61bab90968d56cf7b688a8 Mon Sep 17 00:00:00 2001 From: Mohamed Mansour Date: Tue, 26 Oct 2021 21:15:41 -0700 Subject: [PATCH] sql: Create init script with some conversions for eth/gwei --- migration/init.sql | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 migration/init.sql diff --git a/migration/init.sql b/migration/init.sql new file mode 100644 index 0000000..4356d53 --- /dev/null +++ b/migration/init.sql @@ -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; \ No newline at end of file