Skip to content

Commit 14a995e

Browse files
committed
Add an index based on the new sort plus truncate block_range_root table
We need to truncate the `block_range_root` table since the order of retrieval of the transactions used to compute them has changed.
1 parent 1abad17 commit 14a995e

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

mithril-aggregator/src/database/cardano_transaction_migration.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ create table block_range_root (
7070
merkle_root text not null,
7171
primary key (start, end)
7272
);
73+
"#,
74+
),
75+
// Migration 6
76+
// Add composite index on `block_number/transaction_hash` column of `cardano_tx` table
77+
// Truncate `block_range_root` table after changing the order of retrieval of the transactions
78+
SqlMigration::new(
79+
6,
80+
r#"
81+
create index block_number_transaction_hash_index on cardano_tx(block_number, transaction_hash);
82+
83+
-- remove all data from the block_range_root table since the order used to create them has changed
84+
delete from block_range_root;
85+
86+
vacuum;
7387
"#,
7488
),
7589
]

mithril-signer/src/database/cardano_transaction_migration.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ create table block_range_root (
7070
merkle_root text not null,
7171
primary key (start, end)
7272
);
73+
"#,
74+
),
75+
// Migration 6
76+
// Add composite index on `block_number/transaction_hash` column of `cardano_tx` table
77+
// Truncate `block_range_root` table after changing the order of retrieval of the transactions
78+
SqlMigration::new(
79+
6,
80+
r#"
81+
create index block_number_transaction_hash_index on cardano_tx(block_number, transaction_hash);
82+
83+
-- remove all data from the block_range_root table since the order used to create them has changed
84+
delete from block_range_root;
85+
86+
vacuum;
7387
"#,
7488
),
7589
]

0 commit comments

Comments
 (0)