Skip to content

Commit 8f83a0a

Browse files
authored
feat: batch processed index (#347)
1 parent d6f9818 commit 8f83a0a

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

crates/database/migration/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ mod m20250829_042803_add_table_indexes;
1111
mod m20250901_102341_add_commit_batch_processed_column;
1212
mod m20250904_175949_block_signature;
1313
mod m20250923_135359_add_index_block_hash;
14+
mod m20251001_125444_add_index_processed;
15+
1416
mod migration_info;
1517
pub use migration_info::{
1618
MigrationInfo, ScrollDevMigrationInfo, ScrollMainnetMigrationInfo, ScrollSepoliaMigrationInfo,
@@ -33,6 +35,7 @@ impl<MI: MigrationInfo + Send + Sync + 'static> MigratorTrait for Migrator<MI> {
3335
Box::new(m20250901_102341_add_commit_batch_processed_column::Migration),
3436
Box::new(m20250904_175949_block_signature::Migration),
3537
Box::new(m20250923_135359_add_index_block_hash::Migration),
38+
Box::new(m20251001_125444_add_index_processed::Migration),
3639
]
3740
}
3841
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
use crate::m20220101_000001_create_batch_commit_table::BatchCommit;
2+
3+
use sea_orm_migration::prelude::*;
4+
5+
#[derive(DeriveMigrationName)]
6+
pub struct Migration;
7+
8+
#[async_trait::async_trait]
9+
impl MigrationTrait for Migration {
10+
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
11+
// Add index on `processed` for the `batch_commit` table.
12+
manager
13+
.create_index(
14+
Index::create()
15+
.name("idx_batch_commit_processed")
16+
.col(BatchCommit::Processed)
17+
.table(BatchCommit::Table)
18+
.to_owned(),
19+
)
20+
.await?;
21+
22+
Ok(())
23+
}
24+
25+
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
26+
// Drop index `processed` for the `batch_commit` table.
27+
manager
28+
.drop_index(
29+
Index::drop()
30+
.name("idx_batch_commit_processed")
31+
.table(BatchCommit::Table)
32+
.to_owned(),
33+
)
34+
.await?;
35+
36+
Ok(())
37+
}
38+
}

0 commit comments

Comments
 (0)