2022-11-10 02:58:07 +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> {
|
2022-11-14 09:31:35 +03:00
|
|
|
// note: somehow this column got added in prod, but the migration wasn't marked as complete
|
|
|
|
let _ = manager
|
|
|
|
.alter_table(
|
|
|
|
Table::alter()
|
|
|
|
.table(RpcAccounting::Table)
|
|
|
|
.drop_column(RpcAccounting::Origin)
|
|
|
|
.to_owned(),
|
|
|
|
)
|
|
|
|
.await;
|
|
|
|
|
2022-11-10 02:58:07 +03:00
|
|
|
manager
|
|
|
|
.alter_table(
|
|
|
|
Table::alter()
|
|
|
|
.table(RpcAccounting::Table)
|
|
|
|
.modify_column(
|
|
|
|
ColumnDef::new(RpcAccounting::RpcKeyId)
|
|
|
|
.big_unsigned()
|
|
|
|
.null(),
|
|
|
|
)
|
2022-11-14 09:31:35 +03:00
|
|
|
.add_column(ColumnDef::new(RpcAccounting::Origin).string().null())
|
2022-11-10 02:58:07 +03:00
|
|
|
.to_owned(),
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
|
|
manager
|
|
|
|
.alter_table(
|
|
|
|
Table::alter()
|
|
|
|
.table(RpcAccounting::Table)
|
|
|
|
.modify_column(
|
|
|
|
ColumnDef::new(RpcAccounting::RpcKeyId)
|
|
|
|
.big_unsigned()
|
|
|
|
.not_null(),
|
|
|
|
)
|
|
|
|
.drop_column(RpcAccounting::Origin)
|
|
|
|
.to_owned(),
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Learn more at https://docs.rs/sea-query#iden
|
|
|
|
#[derive(Iden)]
|
|
|
|
enum RpcAccounting {
|
|
|
|
Table,
|
|
|
|
RpcKeyId,
|
|
|
|
Origin,
|
|
|
|
}
|