Skip to content

Commit f64369c

Browse files
authored
feat: add queue index index (#382)
1 parent aac1ba7 commit f64369c

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

crates/database/migration/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ mod m20251001_125444_add_index_processed;
1616
mod m20251005_160938_add_initial_l1_block_numbers;
1717
mod m20251013_140946_add_initial_l1_processed_block_number;
1818
mod m20251021_070729_add_skipped_column;
19+
mod m20251021_144852_add_queue_index_index;
1920

2021
mod migration_info;
2122
pub use migration_info::{
@@ -44,6 +45,7 @@ impl<MI: MigrationInfo + Send + Sync + 'static> MigratorTrait for Migrator<MI> {
4445
Box::new(m20251005_160938_add_initial_l1_block_numbers::Migration),
4546
Box::new(m20251013_140946_add_initial_l1_processed_block_number::Migration),
4647
Box::new(m20251021_070729_add_skipped_column::Migration),
48+
Box::new(m20251021_144852_add_queue_index_index::Migration),
4749
]
4850
}
4951
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use crate::m20250304_125946_add_l1_msg_table::L1Message;
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+
// Add index on `queue_index` for the `l1_message` table.
11+
manager
12+
.create_index(
13+
Index::create()
14+
.name("idx_l1_message_queue_index")
15+
.col(L1Message::QueueIndex)
16+
.table(L1Message::Table)
17+
.to_owned(),
18+
)
19+
.await?;
20+
21+
Ok(())
22+
}
23+
24+
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
25+
// Drop index `queue_index` for the `l1_message` table.
26+
manager
27+
.drop_index(
28+
Index::drop().name("idx_l1_message_queue_index").table(L1Message::Table).to_owned(),
29+
)
30+
.await
31+
}
32+
}

0 commit comments

Comments
 (0)