forgot to git add this
This commit is contained in:
parent
4c2d3634c5
commit
03af6f4dc5
85
migration/src/m20221211_124002_request_method_privacy.rs
Normal file
85
migration/src/m20221211_124002_request_method_privacy.rs
Normal file
@ -0,0 +1,85 @@
|
||||
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> {
|
||||
// allow null method
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Alias::new("rpc_accounting"))
|
||||
.modify_column(ColumnDef::new(Alias::new("method")).string().null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
// existing keys get set to detailed logging
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(RpcKey::Table)
|
||||
.add_column(
|
||||
ColumnDef::new(RpcKey::LogLevel)
|
||||
.enumeration(
|
||||
Alias::new("log_level"),
|
||||
[
|
||||
Alias::new("none"),
|
||||
Alias::new("aggregated"),
|
||||
Alias::new("detailed"),
|
||||
],
|
||||
)
|
||||
.not_null()
|
||||
.default("detailed"),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
// new keys get set to no logging
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(RpcKey::Table)
|
||||
.modify_column(
|
||||
ColumnDef::new(RpcKey::LogLevel)
|
||||
.enumeration(
|
||||
Alias::new("log_level"),
|
||||
[
|
||||
Alias::new("none"),
|
||||
Alias::new("aggregated"),
|
||||
Alias::new("detailed"),
|
||||
],
|
||||
)
|
||||
.not_null()
|
||||
.default("none"),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(RpcKey::Table)
|
||||
.drop_column(RpcKey::LogLevel)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Learn more at https://docs.rs/sea-query#iden
|
||||
#[derive(Iden)]
|
||||
enum RpcKey {
|
||||
Table,
|
||||
LogLevel,
|
||||
}
|
Loading…
Reference in New Issue
Block a user