Ship the corrected bundled SQLite in device components and pinned builds
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user