web3-proxy/migration/src/m20230307_002623_migrate_rpc_accounting_to_rpc_accounting_v2.rs

38 lines
1.0 KiB
Rust
Raw Normal View History

2023-03-07 02:35:04 +03:00
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> {
2023-04-06 00:48:48 +03:00
// Add a nullable timestamp column to check if things were migrated in the rpc_accounting table
2023-03-07 02:35:04 +03:00
manager
.alter_table(
Table::alter()
.table(RpcAccounting::Table)
2023-04-05 22:19:03 +03:00
.add_column(ColumnDef::new(RpcAccounting::Migrated).timestamp())
.to_owned(),
2023-03-07 02:35:04 +03:00
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(RpcAccounting::Table)
.drop_column(RpcAccounting::Migrated)
2023-04-05 22:19:03 +03:00
.to_owned(),
2023-03-07 02:35:04 +03:00
)
.await
}
}
2023-04-06 00:48:48 +03:00
/// partial table for RpcAccounting
2023-03-07 02:35:04 +03:00
#[derive(Iden)]
enum RpcAccounting {
Table,
2023-04-05 22:19:03 +03:00
Migrated,
2023-03-07 02:35:04 +03:00
}