Ship the corrected bundled SQLite in device components and pinned builds

This commit is contained in:
2026-11-18 10:08:01 +01:00
parent 3e6ce7f07c
commit db2f5b407d
12 changed files with 100 additions and 145 deletions
+5 -1
View File
@@ -5,5 +5,9 @@ edition.workspace = true
license.workspace = true
[dependencies]
anyhow.workspace = true
sqlx.workspace = true
# Use the PostgreSQL driver directly. SQLx 0.8's generic migration and type
# features also resolve the obsolete SQLite driver in the shared lockfile.
sqlx = { package = "sqlx-core", version = "=0.8.6", features = ["migrate", "_rt-tokio", "_tls-rustls-ring-webpki"] }
sqlx-macros = { version = "=0.8.6", features = ["migrate"] }
sqlx-postgres = { version = "=0.8.6", features = ["migrate", "chrono", "uuid", "json"] }
uuid.workspace = true
+6 -5
View File
@@ -1,17 +1,18 @@
use anyhow::{Result, ensure};
use sqlx::{PgPool, Postgres, Transaction};
use sqlx::{query::query, query_scalar::query_scalar};
use sqlx_postgres::{PgPool, PgTransaction};
use uuid::Uuid;
pub async fn tenant_tx(pool: &PgPool, tenant: Uuid) -> Result<Transaction<'_, Postgres>> {
pub async fn tenant_tx(pool: &PgPool, tenant: Uuid) -> Result<PgTransaction<'_>> {
let mut tx = pool.begin().await?;
sqlx::query("SELECT set_config('app.tenant_id', $1, true)")
query("SELECT set_config('app.tenant_id', $1, true)")
.bind(tenant.to_string())
.execute(&mut *tx)
.await?;
Ok(tx)
}
pub async fn verify_application_role(pool: &PgPool) -> Result<()> {
let unsafe_role: bool = sqlx::query_scalar(
let unsafe_role: bool = query_scalar(
"SELECT rolsuper OR rolbypassrls OR EXISTS (SELECT 1 FROM pg_tables WHERE schemaname='public' AND tableowner=current_user) FROM pg_roles WHERE rolname=current_user",
).fetch_one(pool).await?;
ensure!(
@@ -22,7 +23,7 @@ pub async fn verify_application_role(pool: &PgPool) -> Result<()> {
}
pub async fn migrate(url: &str) -> Result<()> {
let pool = PgPool::connect(url).await?;
sqlx::migrate!("../../migrations").run(&pool).await?;
sqlx_macros::migrate!("../../migrations").run(&pool).await?;
pool.close().await;
Ok(())
}