Skip to content

Commit

Permalink
Add an index based on the new sort plus truncate block_range_root t…
Browse files Browse the repository at this point in the history
…able

We need to truncate the `block_range_root` table since the order of
retrieval of the transactions used to compute them has changed.
  • Loading branch information
Alenar committed May 7, 2024
1 parent 01e0f60 commit eaba1ae
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mithril-aggregator/src/database/cardano_transaction_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ create table block_range_root (
merkle_root text not null,
primary key (start, end)
);
"#,
),
// Migration 6
// Add composite index on `block_number/transaction_hash` column of `cardano_tx` table
// Truncate `block_range_root` table after changing the order of retrieval of the transactions
SqlMigration::new(
6,
r#"
create index block_number_transaction_hash_index on cardano_tx(block_number, transaction_hash);
-- remove all data from the block_range_root table since the order used to create them has changed
delete from block_range_root;
vacuum;
"#,
),
]
Expand Down
14 changes: 14 additions & 0 deletions mithril-signer/src/database/cardano_transaction_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ create table block_range_root (
merkle_root text not null,
primary key (start, end)
);
"#,
),
// Migration 6
// Add composite index on `block_number/transaction_hash` column of `cardano_tx` table
// Truncate `block_range_root` table after changing the order of retrieval of the transactions
SqlMigration::new(
6,
r#"
create index block_number_transaction_hash_index on cardano_tx(block_number, transaction_hash);
-- remove all data from the block_range_root table since the order used to create them has changed
delete from block_range_root;
vacuum;
"#,
),
]
Expand Down

0 comments on commit eaba1ae

Please sign in to comment.