new feature: order by reference times.

This commit is contained in:
TonyChyi
2022-06-30 22:04:57 +08:00
parent 33142bb470
commit 74f04c3ce0
5 changed files with 76 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ pub use sea_orm_migration::prelude::*;
mod m20220101_000001_create_table;
mod m20220625_222908_message_unique;
mod m20220630_195724_for_hot;
pub struct Migrator;
@@ -11,6 +12,7 @@ impl MigratorTrait for Migrator {
vec![
Box::new(m20220101_000001_create_table::Migration),
Box::new(m20220625_222908_message_unique::Migration),
Box::new(m20220630_195724_for_hot::Migration),
]
}
}

View File

@@ -0,0 +1,37 @@
use models::prelude::Record;
use sea_orm_migration::prelude::*;
pub struct Migration;
impl MigrationName for Migration {
fn name(&self) -> &str {
"m20220630_195724_for_hot"
}
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(Record)
.add_column_if_not_exists(
ColumnDef::new(Alias::new("hot")).big_integer().default(0),
)
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(Record)
.drop_column(Alias::new("hot"))
.to_owned(),
)
.await
}
}