fix(docker): Dockerfile workspace-aware + db.rs create_if_missing
- Contexte de build depuis la racine du workspace Cargo - Rust 1.86 pour edition 2024 - Layer cache avec stubs membres du workspace - Création répertoire /data dans l'image - SQLite create_if_missing(true) pour créer la DB au premier démarrage Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+6
-2
@@ -1,9 +1,13 @@
|
||||
use sqlx::{sqlite::SqlitePoolOptions, SqlitePool};
|
||||
use sqlx::{sqlite::{SqliteConnectOptions, SqlitePoolOptions}, SqlitePool};
|
||||
use std::str::FromStr;
|
||||
|
||||
pub async fn connect(database_url: &str) -> anyhow::Result<SqlitePool> {
|
||||
let opts = SqliteConnectOptions::from_str(database_url)?
|
||||
.create_if_missing(true);
|
||||
|
||||
let pool = SqlitePoolOptions::new()
|
||||
.max_connections(5)
|
||||
.connect(database_url)
|
||||
.connect_with(opts)
|
||||
.await?;
|
||||
|
||||
sqlx::migrate!("./migrations").run(&pool).await?;
|
||||
|
||||
Reference in New Issue
Block a user