MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / get_version

Function get_version

src/db/migrations.rs:22–44  ·  view source on GitHub ↗

Reads the current schema version from `PRAGMA user_version`.

(conn: &Connection)

Source from the content-addressed store, hash-verified

20
21/// Reads the current schema version from `PRAGMA user_version`.
22async fn get_version(conn: &Connection) -> Result<u32> {
23 let mut rows =
24 conn.query("PRAGMA user_version", ())
25 .await
26 .map_err(|e| TraceDecayError::Database {
27 message: format!("failed to read user_version: {e}"),
28 operation: "get_version".to_string(),
29 })?;
30 let row = rows.next().await.map_err(|e| TraceDecayError::Database {
31 message: format!("failed to read user_version row: {e}"),
32 operation: "get_version".to_string(),
33 })?;
34 match row {
35 Some(r) => {
36 let v: i64 = r.get(0).map_err(|e| TraceDecayError::Database {
37 message: format!("failed to read user_version value: {e}"),
38 operation: "get_version".to_string(),
39 })?;
40 Ok(v as u32)
41 }
42 None => Ok(0),
43 }
44}
45
46/// Sets the schema version via `PRAGMA user_version`.
47///

Callers 1

migrateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected