-
Notifications
You must be signed in to change notification settings - Fork 0
/
01.sql
27 lines (25 loc) · 998 Bytes
/
01.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
-- going to be using varchar without a length specified unless I can see
-- some consistent length, it's generally pretty performant these days.
CREATE TABLE IF NOT EXISTS price_feed_checks (
id SERIAL PRIMARY KEY,-- could have also used bigserial here to be safer but
-- doing one check every 5 mins will take around 20.4k years and I don't
-- think this test project is that ambitious.
target VARCHAR,
token VARCHAR, -- needed to add this in for the different coin types
time_stamp TIMESTAMP, -- timestamp is a keyword so rather using time_stamp
price FLOAT
);
CREATE TABLE IF NOT EXISTS price_changes (
id SERIAL PRIMARY KEY,
previous_price_record INT REFERENCES price_feed_checks (id),
latest_price_record INT REFERENCES price_feed_checks (id),
token VARCHAR UNIQUE,
price_change FLOAT
);
CREATE TABLE IF NOT EXISTS logs (
id SERIAL PRIMARY KEY,
process_type VARCHAR,
time_stamp TIMESTAMP,
outcome BOOLEAN,
notes VARCHAR
);