74 lines
1.9 KiB
Rust
74 lines
1.9 KiB
Rust
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
|
|
.alter_table(
|
|
Table::alter()
|
|
.table(User::Table)
|
|
.add_column(
|
|
ColumnDef::new(User::IsIndexable)
|
|
.boolean()
|
|
.not_null()
|
|
.default(true),
|
|
)
|
|
.to_owned(),
|
|
)
|
|
.await?;
|
|
manager
|
|
.alter_table(
|
|
Table::alter()
|
|
.table(UserProfile::Table)
|
|
.add_column(
|
|
ColumnDef::new(UserProfile::IsIndexable)
|
|
.boolean()
|
|
.not_null()
|
|
.default(true),
|
|
)
|
|
.to_owned(),
|
|
)
|
|
.await?;
|
|
|
|
Ok(())
|
|
}
|
|
|
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.alter_table(
|
|
Table::alter()
|
|
.table(User::Table)
|
|
.drop_column(User::IsIndexable)
|
|
.to_owned(),
|
|
)
|
|
.await?;
|
|
manager
|
|
.alter_table(
|
|
Table::alter()
|
|
.table(UserProfile::Table)
|
|
.drop_column(UserProfile::IsIndexable)
|
|
.to_owned(),
|
|
)
|
|
.await?;
|
|
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
/// Learn more at https://docs.rs/sea-query#iden
|
|
#[derive(Iden)]
|
|
enum User {
|
|
Table,
|
|
#[iden = "isIndexable"]
|
|
IsIndexable,
|
|
}
|
|
|
|
#[derive(Iden)]
|
|
enum UserProfile {
|
|
Table,
|
|
#[iden = "isIndexable"]
|
|
IsIndexable,
|
|
}
|