From 70196a49477dfbf8610f6930c727ad37dda59368 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Fri, 26 May 2023 16:32:54 -0700 Subject: [PATCH] Revert "don't drop columns for now" This reverts commit 11e14b12ddf9a364d11e61450983277b75b69631. --- migration/src/lib.rs | 1 + ...emove_columns_statsv2_origin_and_method.rs | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 migration/src/m20230511_161214_remove_columns_statsv2_origin_and_method.rs diff --git a/migration/src/lib.rs b/migration/src/lib.rs index e5090698..c0199867 100644 --- a/migration/src/lib.rs +++ b/migration/src/lib.rs @@ -59,6 +59,7 @@ impl MigratorTrait for Migrator { Box::new(m20230307_002623_migrate_rpc_accounting_to_rpc_accounting_v2::Migration), Box::new(m20230412_171916_modify_secondary_user_add_primary_user::Migration), Box::new(m20230422_172555_premium_downgrade_logic::Migration), + Box::new(m20230511_161214_remove_columns_statsv2_origin_and_method::Migration), Box::new(m20230512_220213_allow_null_rpc_key_id_in_stats_v2::Migration), Box::new(m20230514_114803_admin_add_credits::Migration), ] diff --git a/migration/src/m20230511_161214_remove_columns_statsv2_origin_and_method.rs b/migration/src/m20230511_161214_remove_columns_statsv2_origin_and_method.rs new file mode 100644 index 00000000..a5463c69 --- /dev/null +++ b/migration/src/m20230511_161214_remove_columns_statsv2_origin_and_method.rs @@ -0,0 +1,49 @@ +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(RpcAccountingV2::Table) + .drop_column(RpcAccountingV2::Origin) + .drop_column(RpcAccountingV2::Method) + .to_owned(), + ) + .await + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .alter_table( + Table::alter() + .table(RpcAccountingV2::Table) + .add_column( + ColumnDef::new(RpcAccountingV2::Method) + .string() + .not_null() + .default(""), + ) + .add_column( + ColumnDef::new(RpcAccountingV2::Origin) + .string() + .not_null() + .default(""), + ) + .to_owned(), + ) + .await + } +} + +/// Learn more at https://docs.rs/sea-query#iden +#[derive(Iden)] +enum RpcAccountingV2 { + Table, + Origin, + Method, +}