diff --git a/crates/database/migration/src/lib.rs b/crates/database/migration/src/lib.rs index 5cadddb5..40332012 100644 --- a/crates/database/migration/src/lib.rs +++ b/crates/database/migration/src/lib.rs @@ -11,6 +11,8 @@ mod m20250829_042803_add_table_indexes; mod m20250901_102341_add_commit_batch_processed_column; mod m20250904_175949_block_signature; mod m20250923_135359_add_index_block_hash; +mod m20251001_125444_add_index_processed; + mod migration_info; pub use migration_info::{ MigrationInfo, ScrollDevMigrationInfo, ScrollMainnetMigrationInfo, ScrollSepoliaMigrationInfo, @@ -33,6 +35,7 @@ impl MigratorTrait for Migrator { Box::new(m20250901_102341_add_commit_batch_processed_column::Migration), Box::new(m20250904_175949_block_signature::Migration), Box::new(m20250923_135359_add_index_block_hash::Migration), + Box::new(m20251001_125444_add_index_processed::Migration), ] } } diff --git a/crates/database/migration/src/m20251001_125444_add_index_processed.rs b/crates/database/migration/src/m20251001_125444_add_index_processed.rs new file mode 100644 index 00000000..5a3132ae --- /dev/null +++ b/crates/database/migration/src/m20251001_125444_add_index_processed.rs @@ -0,0 +1,38 @@ +use crate::m20220101_000001_create_batch_commit_table::BatchCommit; + +use sea_orm_migration::prelude::*; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + // Add index on `processed` for the `batch_commit` table. + manager + .create_index( + Index::create() + .name("idx_batch_commit_processed") + .col(BatchCommit::Processed) + .table(BatchCommit::Table) + .to_owned(), + ) + .await?; + + Ok(()) + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + // Drop index `processed` for the `batch_commit` table. + manager + .drop_index( + Index::drop() + .name("idx_batch_commit_processed") + .table(BatchCommit::Table) + .to_owned(), + ) + .await?; + + Ok(()) + } +}