added column to prepare migration

This commit is contained in:
yenicelik 2023-03-07 00:35:04 +01:00
parent ffd63444b2
commit 08e25c48e3
2 changed files with 83 additions and 0 deletions

@ -18,6 +18,7 @@ mod m20230130_124740_read_only_login_logic;
mod m20230130_165144_prepare_admin_imitation_pre_login;
mod m20230215_152254_admin_trail;
mod m20230125_204810_stats_v2;
mod m20230307_002623_migrate_rpc_accounting_to_rpc_accounting_v2;
pub struct Migrator;
@ -43,6 +44,7 @@ impl MigratorTrait for Migrator {
Box::new(m20230130_165144_prepare_admin_imitation_pre_login::Migration),
Box::new(m20230215_152254_admin_trail::Migration),
Box::new(m20230125_204810_stats_v2::Migration),
Box::new(m20230307_002623_migrate_rpc_accounting_to_rpc_accounting_v2::Migration),
]
}
}

@ -0,0 +1,81 @@
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 nullable timestamp column to check if things were migrated in the rpc_accounting table ..
manager
.alter_table(
Table::alter()
.table(RpcAccounting::Table)
.to_owned()
.add_column(
ColumnDef::new(RpcAccounting::Migrated)
.timestamp()
)
.to_owned()
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(RpcAccounting::Table)
.drop_column(RpcAccounting::Migrated)
.to_owned()
)
.await
}
}
/// Learn more at https://docs.rs/sea-query#iden
#[derive(Iden)]
pub enum UserKeys {
Table,
Id,
}
#[derive(Iden)]
enum RpcAccounting {
Table,
Id,
UserKeyId,
ChainId,
Method,
ErrorResponse,
PeriodDatetime,
FrontendRequests,
BackendRequests,
BackendRetries,
NoServers,
CacheMisses,
CacheHits,
SumRequestBytes,
MinRequestBytes,
MeanRequestBytes,
P50RequestBytes,
P90RequestBytes,
P99RequestBytes,
MaxRequestBytes,
SumResponseMillis,
MinResponseMillis,
MeanResponseMillis,
P50ResponseMillis,
P90ResponseMillis,
P99ResponseMillis,
MaxResponseMillis,
SumResponseBytes,
MinResponseBytes,
MeanResponseBytes,
P50ResponseBytes,
P90ResponseBytes,
P99ResponseBytes,
MaxResponseBytes,
Migrated
}