web3-proxy/migration/src/m20230130_124740_read_only_login_logic.rs

42 lines
1.0 KiB
Rust
Raw Normal View History

2023-02-19 23:34:39 +03:00
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> {
// Add a read-only column to the table
2023-02-19 23:34:39 +03:00
manager
.alter_table(
Table::alter()
.table(Login::Table)
2023-03-01 22:23:59 +03:00
.add_column(ColumnDef::new(Login::ReadOnly).boolean().not_null())
.to_owned(),
)
.await
2023-02-19 23:34:39 +03:00
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
// Drop the column from the table ...
manager
.alter_table(
Table::alter()
.table(Login::Table)
.drop_column(Login::ReadOnly)
2023-03-01 22:23:59 +03:00
.to_owned(),
)
.await
2023-02-19 23:34:39 +03:00
}
}
/// Learn more at https://docs.rs/sea-query#iden
#[derive(Iden)]
enum Login {
Table,
2023-03-01 22:23:59 +03:00
// Id,
// BearerToken,
2023-02-19 23:34:39 +03:00
ReadOnly,
2023-03-01 22:23:59 +03:00
// UserId,
2023-02-19 23:34:39 +03:00
}