2022-11-01 21:54:39 +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> {
|
|
|
|
// rename tables from plural to singluar
|
|
|
|
manager
|
|
|
|
.rename_table(
|
|
|
|
Table::rename()
|
|
|
|
.table(Alias::new("revert_logs"), Alias::new("revert_log"))
|
|
|
|
.to_owned(),
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
manager
|
|
|
|
.rename_table(
|
|
|
|
Table::rename()
|
|
|
|
.table(Alias::new("rpc_keys"), Alias::new("rpc_key"))
|
|
|
|
.to_owned(),
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
// on rpc_key table, rename rpc_key to secret_key
|
|
|
|
manager
|
|
|
|
.alter_table(
|
|
|
|
Table::alter()
|
|
|
|
.table(Alias::new("rpc_key"))
|
|
|
|
.rename_column(Alias::new("rpc_key"), Alias::new("secret_key"))
|
|
|
|
.to_owned(),
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
// on revert_log table, rename user_key_id to rpc_key_id
|
|
|
|
manager
|
|
|
|
.alter_table(
|
|
|
|
Table::alter()
|
|
|
|
.table(Alias::new("revert_log"))
|
|
|
|
.rename_column(Alias::new("user_key_id"), Alias::new("rpc_key_id"))
|
|
|
|
.to_owned(),
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
// on rpc_accounting table, rename user_key_id to rpc_key_id
|
|
|
|
manager
|
|
|
|
.alter_table(
|
|
|
|
Table::alter()
|
|
|
|
.table(Alias::new("rpc_accounting"))
|
|
|
|
.rename_column(Alias::new("user_key_id"), Alias::new("rpc_key_id"))
|
|
|
|
.to_owned(),
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
// on secondary_users table, remove "email" and "address" column
|
|
|
|
manager
|
|
|
|
.alter_table(
|
|
|
|
Table::alter()
|
|
|
|
.table(Alias::new("secondary_user"))
|
|
|
|
.drop_column(Alias::new("email"))
|
|
|
|
.drop_column(Alias::new("address"))
|
|
|
|
.to_owned(),
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
|
2022-11-01 22:12:57 +03:00
|
|
|
// on user_tier table, rename requests_per_minute to max_requests_per_period
|
2022-11-01 21:54:39 +03:00
|
|
|
manager
|
|
|
|
.alter_table(
|
|
|
|
Table::alter()
|
|
|
|
.table(Alias::new("user_tier"))
|
|
|
|
.rename_column(
|
|
|
|
Alias::new("requests_per_minute"),
|
2022-11-01 22:12:57 +03:00
|
|
|
Alias::new("max_requests_per_period"),
|
2022-11-01 21:54:39 +03:00
|
|
|
)
|
|
|
|
.to_owned(),
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
manager
|
|
|
|
.alter_table(
|
|
|
|
Table::alter()
|
|
|
|
.table(Alias::new("rpc_key"))
|
|
|
|
.drop_column(Alias::new("log_revert_chance"))
|
|
|
|
.add_column(
|
|
|
|
ColumnDef::new(Alias::new("log_revert_chance"))
|
|
|
|
.double()
|
|
|
|
.not_null()
|
|
|
|
.default(0.0),
|
|
|
|
)
|
|
|
|
.to_owned(),
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> {
|
|
|
|
// Replace the sample below with your own migration scripts
|
2023-09-27 04:18:06 +03:00
|
|
|
unimplemented!();
|
2022-11-01 21:54:39 +03:00
|
|
|
}
|
|
|
|
}
|