feat: remove croxy proxy and image cache features
This commit is contained in:
@@ -77,26 +77,15 @@ impl Application {
|
||||
|
||||
// App State components
|
||||
let db_arc = Arc::new(db);
|
||||
let image_processing_semaphore = Arc::new(tokio::sync::Semaphore::new(
|
||||
CONFIG.image_processing_concurrency,
|
||||
));
|
||||
let event_bus = Arc::new(crate::events::bus::EventBus::new());
|
||||
|
||||
let redis_pool = crate::infrastructure::cache::redis_pool::redis_pool()
|
||||
.map_err(|e| anyhow::anyhow!("Failed to init Redis pool: {}", e))?;
|
||||
|
||||
use crate::infrastructure::repository::SeaOrmImageCacheRepository;
|
||||
let image_cache_repo = Arc::new(SeaOrmImageCacheRepository::new(
|
||||
db_arc.clone(),
|
||||
redis_pool.clone(),
|
||||
));
|
||||
|
||||
let app_state = Arc::new(AppState {
|
||||
redis_pool,
|
||||
db: db_arc.clone(),
|
||||
image_processing_semaphore,
|
||||
event_bus: event_bus.clone(),
|
||||
image_cache_repo,
|
||||
});
|
||||
|
||||
let app = crate::presentation::router::build_router(app_state.clone())?;
|
||||
|
||||
+3
-41
@@ -1,47 +1,9 @@
|
||||
//! Database schema initialization.
|
||||
|
||||
use sea_orm::{ConnectionTrait, DatabaseConnection, Schema, Statement};
|
||||
use sea_orm::DatabaseConnection;
|
||||
use tracing::info;
|
||||
|
||||
use crate::infrastructure::persistence::entities::image_cache;
|
||||
|
||||
pub async fn init(db: &DatabaseConnection) -> Result<(), sea_orm::DbErr> {
|
||||
info!("🚀 Initializing database schema...");
|
||||
let backend = db.get_database_backend();
|
||||
let schema = Schema::new(backend);
|
||||
|
||||
let tables = vec![(
|
||||
"ImageCache",
|
||||
schema
|
||||
.create_table_from_entity(image_cache::Entity)
|
||||
.if_not_exists()
|
||||
.to_owned(),
|
||||
)];
|
||||
|
||||
for (name, stmt) in tables {
|
||||
match db.execute(backend.build(&stmt)).await {
|
||||
Ok(_) => info!(" ✓ Table '{}' checked/created", name),
|
||||
Err(e) => {
|
||||
tracing::error!(" [!] Failed to create table '{}': {}", name, e);
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let index_sql =
|
||||
"CREATE INDEX IF NOT EXISTS idx_image_cache_cdn_url ON \"ImageCache\" (cdn_url)";
|
||||
match db.execute(Statement::from_string(backend, index_sql)).await {
|
||||
Ok(_) => info!(" ✓ Index 'idx_image_cache_cdn_url' ensured"),
|
||||
Err(e) => {
|
||||
let err_str = e.to_string();
|
||||
if err_str.contains("already exists") || err_str.contains("duplicate") {
|
||||
info!(" ✓ Index 'idx_image_cache_cdn_url' already exists");
|
||||
} else {
|
||||
tracing::error!(" [!] Failed to create index on ImageCache: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
info!("✅ Database schema initialization complete.");
|
||||
pub async fn init(_db: &DatabaseConnection) -> Result<(), sea_orm::DbErr> {
|
||||
info!("✅ Database schema initialization complete (no tables to create).");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user