diff options
-rw-r--r-- | src/database.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/database.rs b/src/database.rs index 6a7bde0..8321723 100644 --- a/src/database.rs +++ b/src/database.rs @@ -1,5 +1,6 @@ use rusqlite::Connection; use rusqlite::Result; +use rusqlite::config::DbConfig::{*}; use chrono::Utc; use std::path::PathBuf; @@ -22,7 +23,7 @@ impl Database { pub fn add_register(&self, filepath: &PathBuf) -> Result<()> { let conn = Connection::open(filepath)?; - conn.execute("PRAGMA foreign_key=1", ())?; + conn.set_db_config(SQLITE_DBCONFIG_ENABLE_FKEY, true)?; conn.execute(" INSERT INTO Registers (agent_id, register_date, amount, note) VALUES ( @@ -56,7 +57,7 @@ impl Database { conn.execute(" CREATE TABLE Registers ( id INTEGER PRIMARY KEY, - agent_id INTEGER, + agent_id INTEGER NOT NULL, register_date INTEGER NOT NULL, amount INTEGER NOT NULL, note TEXT, |