Verified Commit 95fc66de authored by Vasili Novikov's avatar Vasili Novikov
Browse files

enforce foreign keys

parent dcda21e9
Showing with 5 additions and 4 deletions
+5 -4
......@@ -42,11 +42,8 @@ async fn main() {
.parent()
.expect("Failed to get parent directory for database");
create_dir_all(sqlite_dir).expect("Failed to create database directory");
let sqlite = SqliteConnectionManager::file(&sqlite_file);
let sqlite: Pool<SqliteConnectionManager> =
r2d2::Pool::new(sqlite).expect("Failed to create r2d2 SQLite connection pool");
// Create a new rusqlite connection for migration, this is a suboptimal solution for now,
// Create a new rusqlite connection for migration. This is a suboptimal solution for now,
// and should be improved later to use the existing connection manager (TODO)
let mut conn = rusqlite::Connection::open(&sqlite_file)
.expect("Failed to open database for refinery migrations");
......@@ -55,6 +52,10 @@ async fn main() {
.expect("Failed to run refinery migrations");
conn.close().expect("Failed to close connection");
let sqlite = SqliteConnectionManager::file(&sqlite_file)
.with_init(|c| c.execute_batch("PRAGMA foreign_keys = ON;"));
let sqlite: Pool<SqliteConnectionManager> =
r2d2::Pool::new(sqlite).expect("Failed to create r2d2 SQLite connection pool");
database_init::init(&sqlite);
// Start web framework
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment