adapter-sqlite: all repo implementations + wire fn + migrations copy

This commit is contained in:
2026-07-12 02:34:12 +02:00
parent 1428f264bb
commit e8179d1f53
29 changed files with 1987 additions and 2 deletions

View File

@@ -0,0 +1,40 @@
//! SQLite adapter for transcode settings (TranscodeSettingsRepository).
use async_trait::async_trait;
use sqlx::SqlitePool;
use domain::{
ports::transcode::TranscodeSettingsRepository,
DomainError, DomainResult,
};
pub struct SqliteTranscodeSettings {
pool: SqlitePool,
}
impl SqliteTranscodeSettings {
pub fn new(pool: SqlitePool) -> Self {
Self { pool }
}
}
#[async_trait]
impl TranscodeSettingsRepository for SqliteTranscodeSettings {
async fn load_cleanup_ttl(&self) -> DomainResult<Option<u32>> {
let row: Option<(i64,)> =
sqlx::query_as("SELECT cleanup_ttl_hours FROM transcode_settings WHERE id = 1")
.fetch_optional(&self.pool)
.await
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
Ok(row.map(|(h,)| h as u32))
}
async fn save_cleanup_ttl(&self, hours: u32) -> DomainResult<()> {
sqlx::query("UPDATE transcode_settings SET cleanup_ttl_hours = ? WHERE id = 1")
.bind(hours as i64)
.execute(&self.pool)
.await
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
Ok(())
}
}