diff options
author | Joris | 2025-02-06 17:53:06 +0100 |
---|---|---|
committer | Joris | 2025-02-06 17:53:06 +0100 |
commit | 232f9d98dd8aaf0302c649066da0375546f8f53a (patch) | |
tree | 4f226421e8f14e024b0deca535e264df3544216f /src/db/utils.rs | |
parent | ad54c0b94d90e1377d86793da611a1f518b5e1f1 (diff) |
Support foreign keys at startup
Diffstat (limited to 'src/db/utils.rs')
-rw-r--r-- | src/db/utils.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/db/utils.rs b/src/db/utils.rs index 2ff0f13..26435e0 100644 --- a/src/db/utils.rs +++ b/src/db/utils.rs @@ -1,5 +1,15 @@ use crate::model::report::Report; -use tokio_rusqlite::Row; +use tokio_rusqlite::{Connection, Row}; + +pub async fn support_foreign_keys(conn: &Connection) { + let query = r#"PRAGMA foreign_keys = ON"#; + + let res = conn.call(move |conn| Ok(conn.execute(query, [])?)).await; + + if let Err(err) = res { + log::error!("Error supporting foreign keys: {err:?}"); + } +} pub fn format_key_for_search(value: &str) -> String { // Lower doesn’t work on accentuated letters, hence the need to remove manually accents for |