forked from denaro-coin/denaro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.sql
28 lines (25 loc) · 814 Bytes
/
schema.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
28
CREATE TABLE IF NOT EXISTS blocks (
id SERIAL PRIMARY KEY,
hash CHAR(64) UNIQUE,
address CHAR(128) NOT NULL,
random BIGINT NOT NULL,
difficulty NUMERIC(3, 1) NOT NULL,
reward NUMERIC(14, 6) NOT NULL,
timestamp TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP(0)
);
CREATE TABLE IF NOT EXISTS transactions (
block_hash CHAR(64) NOT NULL REFERENCES blocks(hash) ON DELETE CASCADE,
tx_hash CHAR(64) UNIQUE,
tx_hex VARCHAR(2048) UNIQUE,
inputs_addresses TEXT[],
fees NUMERIC(14, 6) NOT NULL
);
CREATE TABLE IF NOT EXISTS pending_transactions (
tx_hash CHAR(64) UNIQUE,
tx_hex VARCHAR(2048) UNIQUE,
inputs_addresses TEXT[],
fees NUMERIC(14, 6) NOT NULL
);
-- if your user is denaro
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO denaro;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO denaro;