web3-proxy/migration/src/m20221031_211916_clean_up.rs
Bryan Stitt f0b6465069
streaming responses 2 (#219)
* streaming responses compile, still small TODOs & cleanup

* refactor to allow short curcuits on uncacheable requests (#220)

* refactor to allow short curcuits on uncacheable requests

* handle error inside an Arc from moka

* arc instead of box

* lint

* more lint

* add bonus rate limits and keep all semaphores after rate limits (#221)

* add bonus rate limits and keep all semaphores after rate limits

* remove stale todos

* better function names

* cargo upgrade and update

* make some panics warn. more todo

* pass request_metadata through so streaming responses include their final size

* remove stale TODO

* remove more stale todos

* add file i missed

* make to_json_string work well enough

* check config for free_subscriptions

---------

Co-authored-by: Rory Neithinger <rory@llamanodes.com>
2023-09-26 18:18:06 -07:00

103 lines
3.2 KiB
Rust

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?;
// on user_tier table, rename requests_per_minute to max_requests_per_period
manager
.alter_table(
Table::alter()
.table(Alias::new("user_tier"))
.rename_column(
Alias::new("requests_per_minute"),
Alias::new("max_requests_per_period"),
)
.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
unimplemented!();
}
}