@@ -3,37 +3,33 @@ CREATE TABLE channels
3
3
id VARCHAR (66 ) NOT NULL ,
4
4
creator VARCHAR (255 ) NOT NULL ,
5
5
deposit_asset VARCHAR (42 ) NOT NULL ,
6
- deposit_amount VARCHAR (255 ) NOT NULL , -- @TODO change the deposit to BigNum compatible field
6
+ deposit_amount VARCHAR (255 ) NOT NULL ,
7
7
valid_until TIMESTAMP WITH TIME ZONE NOT NULL ,
8
8
spec JSONB NOT NULL ,
9
9
10
10
PRIMARY KEY (id)
11
11
);
12
12
13
- CREATE INDEX idx_valid_until ON channels (valid_until);
14
- CREATE INDEX idx_spec ON channels ((spec - > ' validator ' - >> ' id ' ));
13
+ CREATE INDEX idx_channel_valid_until ON channels (valid_until);
14
+ CREATE INDEX idx_channels_spec_created ON channels ((spec - >> ' created ' ));
15
15
16
16
CREATE TABLE validator_messages
17
17
(
18
18
channel_id VARCHAR (66 ) NOT NULL REFERENCES channels (id) ON DELETE RESTRICT,
19
19
" from" VARCHAR (255 ) NOT NULL ,
20
20
msg JSONB NOT NULL ,
21
- received TIMESTAMP WITH TIME ZONE NOT NULL ,
22
-
23
- PRIMARY KEY (channel_id)
21
+ received TIMESTAMP WITH TIME ZONE NOT NULL
24
22
);
25
23
26
- CREATE INDEX idx_received ON validator_messages (received);
27
- CREATE INDEX ON validator_messages ((msg - >> ' type' ));
28
- CREATE INDEX ON validator_messages ((msg - >> ' stateRoot' ));
24
+ CREATE INDEX idx_validator_messages_received ON validator_messages (received);
25
+ CREATE INDEX idx_validator_messages_msg_type ON validator_messages ((msg - >> ' type' ));
26
+ CREATE INDEX idx_validator_messages_msg_state_root ON validator_messages ((msg - >> ' stateRoot' ));
29
27
30
28
CREATE TABLE event_aggregates
31
29
(
32
30
channel_id VARCHAR (66 ) NOT NULL REFERENCES channels (id) ON DELETE RESTRICT,
33
31
created TIMESTAMP WITH TIME ZONE NOT NULL ,
34
- events JSONB NOT NULL ,
35
-
36
- PRIMARY KEY (channel_id)
32
+ events JSONB NOT NULL
37
33
);
38
34
39
- CREATE INDEX idx_created ON event_aggregates (created);
35
+ CREATE INDEX idx_event_aggregates_created ON event_aggregates (created);
0 commit comments