From 2c336f0339747aa77a8fe6613b83200c8d4902a5 Mon Sep 17 00:00:00 2001 From: rtkay123 Date: Tue, 31 Mar 2026 21:35:49 +0200 Subject: test(config): schema --- lib/api-config/src/schema/update_schema.rs | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/api-config/src/schema/update_schema.rs (limited to 'lib/api-config/src/schema/update_schema.rs') diff --git a/lib/api-config/src/schema/update_schema.rs b/lib/api-config/src/schema/update_schema.rs new file mode 100644 index 0000000..4aa0862 --- /dev/null +++ b/lib/api-config/src/schema/update_schema.rs @@ -0,0 +1,34 @@ +use tracing::debug; + +use crate::{ + ConfigurationError, + schema::{SchemaService, TransactionSchema}, +}; + +pub(super) async fn update_schema( + state: &SchemaService, + kind: &str, + version: &str, + schema: &serde_json::Value, +) -> Result, ConfigurationError> { + debug!("updating transaction schema"); + sqlx::query_as!( + TransactionSchema, + " + update + transaction_schema + set + schema = $3 + where + schema_type = $1 + and schema_version = $2 + returning * + ", + kind, + version, + sqlx::types::Json(&schema) as _ + ) + .fetch_optional(&state.database) + .await + .map_err(|e| e.into()) +} -- cgit v1.2.3