parent
47c2947b77
commit
3779b77c25
2 changed files with 0 additions and 31 deletions
|
@ -3,7 +3,6 @@ pub use sea_orm_migration::prelude::*;
|
||||||
mod m20230531_180824_drop_reversi;
|
mod m20230531_180824_drop_reversi;
|
||||||
mod m20230627_185451_index_note_url;
|
mod m20230627_185451_index_note_url;
|
||||||
mod m20230709_000510_move_antenna_to_cache;
|
mod m20230709_000510_move_antenna_to_cache;
|
||||||
mod m20230716_164152_clear_user_cache;
|
|
||||||
|
|
||||||
pub struct Migrator;
|
pub struct Migrator;
|
||||||
|
|
||||||
|
@ -14,7 +13,6 @@ impl MigratorTrait for Migrator {
|
||||||
Box::new(m20230531_180824_drop_reversi::Migration),
|
Box::new(m20230531_180824_drop_reversi::Migration),
|
||||||
Box::new(m20230627_185451_index_note_url::Migration),
|
Box::new(m20230627_185451_index_note_url::Migration),
|
||||||
Box::new(m20230709_000510_move_antenna_to_cache::Migration),
|
Box::new(m20230709_000510_move_antenna_to_cache::Migration),
|
||||||
Box::new(m20230716_164152_clear_user_cache::Migration),
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
use redis::Commands;
|
|
||||||
use sea_orm_migration::prelude::*;
|
|
||||||
use std::env;
|
|
||||||
|
|
||||||
#[derive(DeriveMigrationName)]
|
|
||||||
pub struct Migration;
|
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
|
||||||
impl MigrationTrait for Migration {
|
|
||||||
async fn up(&self, _manager: &SchemaManager) -> Result<(), DbErr> {
|
|
||||||
let cache_url = env::var("CACHE_URL").unwrap();
|
|
||||||
let prefix = env::var("CACHE_PREFIX").unwrap();
|
|
||||||
let client = redis::Client::open(cache_url).unwrap();
|
|
||||||
let mut redis_conn = client.get_connection().unwrap();
|
|
||||||
let keys: Vec<String> = redis_conn
|
|
||||||
.keys(format!("{prefix}:cache:userById:*")).unwrap();
|
|
||||||
|
|
||||||
if !keys.is_empty() {
|
|
||||||
println!("Deleting {} keys from the cache server.", keys.len());
|
|
||||||
redis_conn.del::<_, i32>(keys).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue