-
Notifications
You must be signed in to change notification settings - Fork 228
/
create_postgres_table.sql
77 lines (69 loc) · 1.63 KB
/
create_postgres_table.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
CREATE TABLE block(
id BIGSERIAL PRIMARY KEY,
block_hash BYTEA NOT NULL,
block_number BIGINT NOT NULL,
compact_target BYTEA,
parent_hash BYTEA,
nonce BYTEA,
timestamp BIGINT,
version BYTEA,
transactions_root BYTEA,
epoch BYTEA,
dao BYTEA,
proposals_hash BYTEA,
extra_hash BYTEA,
extension BYTEA
);
CREATE TABLE block_association_proposal(
id BIGSERIAL,
block_id BIGINT NOT NULL,
proposal BYTEA NOT NULL
);
CREATE TABLE block_association_uncle(
id BIGSERIAL,
block_id BIGINT NOT NULL,
uncle_id BIGINT NOT NULL
);
CREATE TABLE ckb_transaction(
id BIGSERIAL PRIMARY KEY,
tx_hash BYTEA NOT NULL,
version BYTEA NOT NULL,
input_count INTEGER NOT NULL,
output_count INTEGER NOT NULL,
witnesses BYTEA,
block_id BIGINT NOT NULL,
tx_index INTEGER NOT NULL
);
CREATE TABLE tx_association_header_dep(
id BIGSERIAL,
tx_id BIGINT NOT NULL,
block_id BIGINT NOT NULL
);
CREATE TABLE tx_association_cell_dep(
id BIGSERIAL,
tx_id BIGINT NOT NULL,
output_id BIGINT NOT NULL,
dep_type SMALLINT NOT NULL
);
CREATE TABLE output(
id BIGSERIAL PRIMARY KEY,
tx_id BIGINT NOT NULL,
output_index INTEGER NOT NULL,
capacity BIGINT NOT NULL,
lock_script_id BIGINT,
type_script_id BIGINT,
data BYTEA
);
CREATE TABLE input(
output_id BIGINT PRIMARY KEY,
since BYTEA NOT NULL,
consumed_tx_id BIGINT NOT NULL,
input_index INTEGER NOT NULL
);
CREATE TABLE script(
id BIGSERIAL PRIMARY KEY,
code_hash BYTEA NOT NULL,
hash_type SMALLINT NOT NULL,
args BYTEA,
UNIQUE(code_hash, hash_type, args)
);