Skip to content
This repository was archived by the owner on Apr 9, 2024. It is now read-only.

Commit 124290b

Browse files
authored
fix(sync): re-create table should re-create index too. (#378)
1 parent ee90f8f commit 124290b

File tree

1 file changed

+18
-4
lines changed
  • core/synchronization/src

1 file changed

+18
-4
lines changed

core/synchronization/src/sql.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ pub async fn drop_consume_info_table(tx: &mut RBatisTxExecutor<'_>) -> () {}
5151

5252
#[sql(
5353
tx,
54-
"CREATE TABLE mercury_live_cell(
54+
"
55+
CREATE TABLE mercury_live_cell(
5556
id bigint PRIMARY KEY,
5657
tx_hash bytea NOT NULL,
5758
output_index int NOT NULL,
@@ -71,20 +72,33 @@ pub async fn drop_consume_info_table(tx: &mut RBatisTxExecutor<'_>) -> () {}
7172
type_args bytea,
7273
type_script_type smallint,
7374
data bytea
74-
)"
75+
);
76+
CREATE INDEX \"index_live_cell_table_block_hash\" ON \"mercury_live_cell\" (\"block_hash\");
77+
CREATE INDEX \"index_live_cell_table_block_number\" ON \"mercury_live_cell\" (\"block_number\");
78+
CREATE INDEX \"index_live_cell_table_tx_hash_and_output_index\" ON \"mercury_live_cell\" (\"tx_hash\", \"output_index\");
79+
CREATE INDEX \"index_live_cell_table_lock_hash\" ON \"mercury_live_cell\" (\"lock_hash\");
80+
CREATE INDEX \"index_live_cell_table_lock_code_hash_and_lock_script_type\" ON \"mercury_live_cell\" (\"lock_code_hash\", \"lock_script_type\");
81+
CREATE INDEX \"index_live_cell_table_type_code_hash_and_type_script_type\" ON \"mercury_live_cell\" (\"type_code_hash\", \"type_script_type\");
82+
"
7583
)]
7684
pub async fn create_live_cell_table(tx: &mut RBatisTxExecutor<'_>) -> () {}
7785

7886
#[sql(
7987
tx,
80-
"CREATE TABLE mercury_script(
88+
"
89+
CREATE TABLE mercury_script(
8190
script_hash bytea NOT NULL PRIMARY KEY,
8291
script_hash_160 bytea NOT NULL,
8392
script_code_hash bytea NOT NULL,
8493
script_args bytea,
8594
script_type smallint NOT NULL,
8695
script_args_len int
87-
);"
96+
);
97+
CREATE INDEX \"index_script_table_script_hash\" ON \"mercury_script\" (\"script_hash\");
98+
CREATE INDEX \"index_script_table_code_hash\" ON \"mercury_script\" (\"script_code_hash\");
99+
CREATE INDEX \"index_script_table_args\" ON \"mercury_script\" (\"script_args\");
100+
CREATE INDEX \"index_script_table_script_hash_160\" ON \"mercury_script\" USING btree (\"script_hash_160\");
101+
",
88102
)]
89103
pub async fn create_script_table(tx: &mut RBatisTxExecutor<'_>) -> () {}
90104

0 commit comments

Comments
 (0)