This commit is contained in:
2026-08-08 14:57:04 +02:00
parent 0d8c86af16
commit d1f9234457
5 changed files with 56 additions and 38 deletions
+1 -5
View File
@@ -1,16 +1,12 @@
pub use sea_orm_migration::prelude::*;
mod m20220101_000001_create_table;
mod m20260808_000002_add_message_channel_id_id_index;
pub struct Migrator;
#[async_trait::async_trait]
impl MigratorTrait for Migrator {
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
vec![
Box::new(m20220101_000001_create_table::Migration),
Box::new(m20260808_000002_add_message_channel_id_id_index::Migration),
]
vec![Box::new(m20220101_000001_create_table::Migration)]
}
}
@@ -505,6 +505,12 @@ impl MigrationTrait for Migration {
.to(Alias::new("message"), Alias::new("id"))
.on_delete(ForeignKeyAction::SetNull),
)
.index(
Index::create()
.name("idx_message_channel_id_id")
.col(Alias::new("channel_id"))
.col(Alias::new("id")),
)
.to_owned(),
)
.await?;
@@ -1,31 +0,0 @@
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> {
manager
.create_index(
Index::create()
.name("idx_message_channel_id_id")
.table(Alias::new("message"))
.col(Alias::new("channel_id"))
.col(Alias::new("id"))
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_index(
Index::drop()
.name("idx_message_channel_id_id")
.table(Alias::new("message"))
.to_owned(),
)
.await
}
}