You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.2 KiB
Rust
83 lines
2.2 KiB
Rust
use crate::{DbErr, Table};
|
|
use sea_orm_migration::prelude::*;
|
|
|
|
#[derive(Iden)]
|
|
pub enum Statistics {
|
|
Table,
|
|
ExecutedAt,
|
|
}
|
|
|
|
#[derive(Iden)]
|
|
pub enum EphemeralMessages {
|
|
Table,
|
|
Timeout,
|
|
}
|
|
|
|
pub struct Migration;
|
|
|
|
impl MigrationName for Migration {
|
|
fn name(&self) -> &str {
|
|
"m20220029_164527_change_timestamp_format"
|
|
}
|
|
}
|
|
|
|
#[async_trait::async_trait]
|
|
impl MigrationTrait for Migration {
|
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.alter_table(
|
|
Table::alter()
|
|
.table(Statistics::Table)
|
|
.modify_column(
|
|
ColumnDef::new(Statistics::ExecutedAt)
|
|
.timestamp_with_time_zone()
|
|
.not_null(),
|
|
)
|
|
.to_owned(),
|
|
)
|
|
.await?;
|
|
manager
|
|
.alter_table(
|
|
Table::alter()
|
|
.table(EphemeralMessages::Table)
|
|
.modify_column(
|
|
ColumnDef::new(EphemeralMessages::Timeout)
|
|
.timestamp_with_time_zone()
|
|
.not_null(),
|
|
)
|
|
.to_owned(),
|
|
)
|
|
.await?;
|
|
Ok(())
|
|
}
|
|
|
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.alter_table(
|
|
Table::alter()
|
|
.table(Statistics::Table)
|
|
.modify_column(
|
|
ColumnDef::new(Statistics::ExecutedAt)
|
|
.timestamp()
|
|
.not_null(),
|
|
)
|
|
.to_owned(),
|
|
)
|
|
.await?;
|
|
manager
|
|
.alter_table(
|
|
Table::alter()
|
|
.table(EphemeralMessages::Table)
|
|
.modify_column(
|
|
ColumnDef::new(EphemeralMessages::Timeout)
|
|
.timestamp()
|
|
.not_null(),
|
|
)
|
|
.to_owned(),
|
|
)
|
|
.await?;
|
|
|
|
Ok(())
|
|
}
|
|
}
|