Files
Infrastruktur-Monitoring-Sy…/backend/crates/infrastructure/src/db.rs
Dennis Nemec f1136fdf3d
Some checks failed
CI / backend (push) Has been cancelled
CI / frontend (push) Has been cancelled
CI / ui (push) Has been cancelled
WP-01: authentication, user management and application shell
Argon2id password hashing, JWT access tokens with rotating HttpOnly refresh
cookies and reuse detection, login rate limiting, auth audit log, bootstrap
admin, admin-only user CRUD and password reset, OpenAPI spec. Vue login page,
auth store with automatic token refresh, route guards, sidebar shell with
toasts and placeholder pages, user management page.

All tests green: 40 backend, 12 Vitest, 4 Playwright.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-02 21:37:14 +02:00

18 lines
573 B
Rust

use sqlx::sqlite::{SqlitePool, SqlitePoolOptions};
pub type DbPool = SqlitePool;
/// Connect and run migrations. In-memory URLs get a single connection so the schema persists.
pub async fn connect(url: &str) -> anyhow::Result<DbPool> {
let in_memory = url.contains(":memory:");
let pool = SqlitePoolOptions::new()
.max_connections(if in_memory { 1 } else { 5 })
.connect(url)
.await?;
sqlx::query("PRAGMA foreign_keys = ON")
.execute(&pool)
.await?;
sqlx::migrate!("./migrations").run(&pool).await?;
Ok(pool)
}