Skip to main content

max / makenotwork

pom: enable SQLite foreign_keys enforcement Set foreign_keys(true) on both the on-disk and in-memory connect paths so the declared ON DELETE CASCADE on test_details actually fires instead of relying solely on the manual orphan sweep. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author: Max Johnson <me@maxj.phd> · 2026-07-11 00:52 UTC
Commit: b17af872db14a73626958205871dafcc83eb2ff7
Parent: 04e2e80
1 file changed, +2 insertions, -1 deletion
M pom/src/db.rs +2 -1
@@ -200,6 +200,7 @@ const MIGRATIONS: &[(i64, &str, &str)] = &[
200 200 pub async fn connect(path: &Path) -> Result<SqlitePool> {
201 201 let opts = SqliteConnectOptions::from_str(&format!("sqlite:{}", path.display()))?
202 202 .create_if_missing(true)
203 + .foreign_keys(true)
203 204 .journal_mode(sqlx::sqlite::SqliteJournalMode::Wal);
204 205
205 206 let pool = SqlitePoolOptions::new()
@@ -213,7 +214,7 @@ pub async fn connect(path: &Path) -> Result<SqlitePool> {
213 214
214 215 #[instrument(skip_all)]
215 216 pub async fn connect_in_memory() -> Result<SqlitePool> {
216 - let opts = SqliteConnectOptions::from_str("sqlite::memory:")?;
217 + let opts = SqliteConnectOptions::from_str("sqlite::memory:")?.foreign_keys(true);
217 218 let pool = SqlitePoolOptions::new()
218 219 .max_connections(1)
219 220 .connect_with(opts)