Reads the current schema version from `PRAGMA user_version`.
(conn: &Connection)
| 20 | |
| 21 | /// Reads the current schema version from `PRAGMA user_version`. |
| 22 | async 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 | /// |