web3-proxy/migration/src/m20230512_220213_allow_null_rpc_key_id_in_stats_v2.rs

49 lines
1.4 KiB
Rust
Raw Normal View History

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(
sea_query::Table::alter()
.table(RpcAccountingV2::Table)
.to_owned()
// allow rpc_key_id to be null. Needed for public rpc stat tracking
.modify_column(
ColumnDef::new(RpcAccountingV2::RpcKeyId)
.big_unsigned()
.null(),
)
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
sea_query::Table::alter()
.table(RpcAccountingV2::Table)
.to_owned()
.modify_column(
ColumnDef::new(RpcAccountingV2::RpcKeyId)
.big_unsigned()
.not_null()
.default(0),
)
.to_owned(),
)
.await
}
}
/// Learn more at https://docs.rs/sea-query#iden
#[derive(Iden)]
enum RpcAccountingV2 {
Table,
RpcKeyId,
}