From c16f7bd1bae674e2675cd1b62211a077f6c25b98 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Tue, 20 Jun 2023 19:12:20 -0700 Subject: [PATCH] copy default_tracking migration from devel --- Cargo.lock | 2 +- migration/Cargo.toml | 2 +- migration/src/lib.rs | 2 + .../src/m20230619_172237_default_tracking.rs | 63 +++++++++++++++++++ 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 migration/src/m20230619_172237_default_tracking.rs diff --git a/Cargo.lock b/Cargo.lock index d551fc1a..aecd588a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3330,7 +3330,7 @@ dependencies = [ [[package]] name = "migration" -version = "0.31.0" +version = "0.32.0" dependencies = [ "sea-orm-migration", "tokio", diff --git a/migration/Cargo.toml b/migration/Cargo.toml index 7b07bccb..9dbae336 100644 --- a/migration/Cargo.toml +++ b/migration/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "migration" -version = "0.31.0" +version = "0.32.0" edition = "2021" publish = false diff --git a/migration/src/lib.rs b/migration/src/lib.rs index 86596da2..95cb3f19 100644 --- a/migration/src/lib.rs +++ b/migration/src/lib.rs @@ -31,6 +31,7 @@ mod m20230514_114803_admin_add_credits; mod m20230607_221917_total_deposits; mod m20230615_221201_handle_payment_uncles; mod m20230618_230611_longer_payload; +mod m20230619_172237_default_tracking; pub struct Migrator; @@ -69,6 +70,7 @@ impl MigratorTrait for Migrator { Box::new(m20230607_221917_total_deposits::Migration), Box::new(m20230615_221201_handle_payment_uncles::Migration), Box::new(m20230618_230611_longer_payload::Migration), + Box::new(m20230619_172237_default_tracking::Migraiton), ] } } diff --git a/migration/src/m20230619_172237_default_tracking.rs b/migration/src/m20230619_172237_default_tracking.rs new file mode 100644 index 00000000..aca4fb54 --- /dev/null +++ b/migration/src/m20230619_172237_default_tracking.rs @@ -0,0 +1,63 @@ +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> { + // new keys get set to aggregated logging + // TODO: rename "none" to "minimal" + 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("detailed"), + ) + .to_owned(), + ) + .await + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + // new keys get set to none 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 + } +} + +/// Learn more at https://docs.rs/sea-query#iden +#[derive(Iden)] +enum RpcKey { + Table, + LogLevel, +}