Skip to content

Commit 627e9cc

Browse files
committed
update initial-tables migration indices and make it compatible with migrant
1 parent 4d61fef commit 627e9cc

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

sentry/migrations/20190806011140_initial_tables/up.sql renamed to sentry/migrations/20190806011140_initial-tables/up.sql

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,33 @@ CREATE TABLE channels
33
id VARCHAR(66) NOT NULL,
44
creator VARCHAR(255) NOT NULL,
55
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,
77
valid_until TIMESTAMP WITH TIME ZONE NOT NULL,
88
spec JSONB NOT NULL,
99

1010
PRIMARY KEY (id)
1111
);
1212

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'));
1515

1616
CREATE TABLE validator_messages
1717
(
1818
channel_id VARCHAR(66) NOT NULL REFERENCES channels (id) ON DELETE RESTRICT,
1919
"from" VARCHAR(255) NOT NULL,
2020
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
2422
);
2523

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'));
2927

3028
CREATE TABLE event_aggregates
3129
(
3230
channel_id VARCHAR(66) NOT NULL REFERENCES channels (id) ON DELETE RESTRICT,
3331
created TIMESTAMP WITH TIME ZONE NOT NULL,
34-
events JSONB NOT NULL,
35-
36-
PRIMARY KEY (channel_id)
32+
events JSONB NOT NULL
3733
);
3834

39-
CREATE INDEX idx_created ON event_aggregates (created);
35+
CREATE INDEX idx_event_aggregates_created ON event_aggregates (created);

sentry/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub async fn setup_migrations() {
7878

7979
// Define Migrations
8080
config
81-
.use_migrations(&[make_migration!("20190806011140_initial_tables")])
81+
.use_migrations(&[make_migration!("20190806011140_initial-tables")])
8282
.expect("Loading migrations failed");
8383

8484
// Reload config, ping the database for applied migrations

0 commit comments

Comments
 (0)