fix(server): create SQLite database file if missing on first start
Build and Deploy / build-and-push (push) Successful in 1m15s

SqlitePool::connect defaults create_if_missing=false in SQLx 0.8, causing
SQLITE_CANTOPEN (error 14) when the PVC is empty on first deploy.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
funman300
2026-05-13 15:44:16 -07:00
parent 6e3ce8ea59
commit 022a749f5f
+12 -3
View File
@@ -32,9 +32,10 @@
//! ```
use solitaire_server::{build_router, AppState};
use sqlx::SqlitePool;
use sqlx::{sqlite::SqliteConnectOptions, SqlitePool};
use std::{
io::{self, BufRead},
str::FromStr,
net::SocketAddr,
};
@@ -64,7 +65,11 @@ async fn main() {
async fn run_reset_password(username: &str) {
let db_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let pool = SqlitePool::connect(&db_url)
let pool = SqlitePool::connect_with(
SqliteConnectOptions::from_str(&db_url)
.expect("invalid DATABASE_URL")
.create_if_missing(true),
)
.await
.expect("failed to connect to database");
@@ -105,7 +110,11 @@ async fn run_server() {
.parse()
.expect("SERVER_PORT must be a valid port number");
let pool = SqlitePool::connect(&db_url)
let pool = SqlitePool::connect_with(
SqliteConnectOptions::from_str(&db_url)
.expect("invalid DATABASE_URL")
.create_if_missing(true),
)
.await
.expect("failed to connect to database");