mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-19 21:18:16 +02:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG2LLJuswrrTTPKJmunEVf
20 lines
724 B
Rust
20 lines
724 B
Rust
//! Schéma de la base, joué à chaque démarrage (idempotent).
|
|
|
|
const INIT_SQL: &str = include_str!("../sql/init.sql");
|
|
|
|
pub async fn run() {
|
|
tracing::info!("[DB Init] Starting database migration & initialization...");
|
|
let pool = match crate::db::pool() {
|
|
Ok(p) => p,
|
|
Err(_) => {
|
|
tracing::warn!("[DB Init] No DATABASE_URL found in env or config. Skipping.");
|
|
return;
|
|
}
|
|
};
|
|
match sqlx::raw_sql(INIT_SQL).execute(&pool).await {
|
|
Ok(_) => tracing::info!("[DB Init] Initialization successful."),
|
|
// L'application reste utilisable (comptes de secours, Paramètres).
|
|
Err(e) => tracing::error!("[DB Init] Initialization failed: {e}"),
|
|
}
|
|
}
|