Skip to content

Commit fbfd7c8

Browse files
authored
feat(database): add index block_hash for table block_signature (#340)
1 parent 84e8cfe commit fbfd7c8

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

crates/database/migration/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ mod m20250825_093350_remove_unsafe_l2_blocks;
1010
mod m20250829_042803_add_table_indexes;
1111
mod m20250901_102341_add_commit_batch_processed_column;
1212
mod m20250904_175949_block_signature;
13+
mod m20250923_135359_add_index_block_hash;
1314
mod migration_info;
1415
pub use migration_info::{
1516
MigrationInfo, ScrollDevMigrationInfo, ScrollMainnetMigrationInfo, ScrollSepoliaMigrationInfo,
@@ -31,6 +32,7 @@ impl<MI: MigrationInfo + Send + Sync + 'static> MigratorTrait for Migrator<MI> {
3132
Box::new(m20250829_042803_add_table_indexes::Migration),
3233
Box::new(m20250901_102341_add_commit_batch_processed_column::Migration),
3334
Box::new(m20250904_175949_block_signature::Migration),
35+
Box::new(m20250923_135359_add_index_block_hash::Migration),
3436
]
3537
}
3638
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use super::m20250904_175949_block_signature::BlockSignature;
2+
use sea_orm_migration::prelude::*;
3+
4+
#[derive(DeriveMigrationName)]
5+
pub struct Migration;
6+
7+
#[async_trait::async_trait]
8+
impl MigrationTrait for Migration {
9+
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
10+
// Create indexes for the `block_signature` table.
11+
manager
12+
.create_index(
13+
Index::create()
14+
.name("idx_block_signature_block_hash")
15+
.col(BlockSignature::BlockHash)
16+
.table(BlockSignature::Table)
17+
.to_owned(),
18+
)
19+
.await?;
20+
21+
Ok(())
22+
}
23+
24+
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
25+
// Drop indexes for the `block_signature` table.
26+
manager
27+
.drop_index(
28+
Index::drop()
29+
.name("idx_block_signature_block_hash")
30+
.table(BlockSignature::Table)
31+
.to_owned(),
32+
)
33+
.await?;
34+
35+
Ok(())
36+
}
37+
}

0 commit comments

Comments
 (0)