Enable SQLite foreign keys explicitly in App
Pass foreign_keys: true to Sequel.sqlite so referential integrity is
pinned and the intent is visible. Sequel's SQLite adapter already
enables the pragma by default, so this is behavior-preserving (the
suite passes unchanged). Correct the sequel skill note, which wrongly
claimed foreign keys were off.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQTgGstuG7U9yzrtK6emxy
change
commit fdd7e094317762d1f7126b7e5ff12b9917ee9fb8
author Claude <noreply@anthropic.com>
date
parent 48f91163
diff --git a/.claude/skills/sequel/SKILL.md b/.claude/skills/sequel/SKILL.md
index 32602d1..93fec86 100644
--- a/.claude/skills/sequel/SKILL.md
+++ b/.claude/skills/sequel/SKILL.md
@@ -13,7 +13,8 @@ Roda app's `opts`.
 
 ```ruby
 # lib/app.rb
-@db = Sequel.sqlite(config.database_url)   # file path, or ":memory:" in tests
+@db = Sequel.sqlite(config.database_url, foreign_keys: true)
+#                   file path, or ":memory:" in tests
 ```
 
 `App#db` is the `Sequel::Database`. Routes reach it via `app.db` (see the
@@ -21,11 +22,11 @@ Roda app's `opts`.
 migrations into it (`test/test_helper.rb`). A `:memory:` database is private to
 its single connection — fine for the test suite's one-connection use.
 
-> **SQLite foreign keys are OFF by default.** Sequel doesn't enable them unless
-> you pass `foreign_keys: true` to `Sequel.sqlite`. So the `foreign_key`
-> columns in the schema document intent and create indexes, but SQLite is not
-> currently enforcing referential integrity at runtime. Keep that in mind
-> before relying on cascade/restrict behavior.
+> **Foreign keys are enforced.** Raw SQLite leaves `PRAGMA foreign_keys` off,
+> but Sequel's SQLite adapter turns it on for every connection by default, and
+> `lib/app.rb` also passes `foreign_keys: true` explicitly so the intent is
+> visible and pinned. So the `foreign_key` columns enforce referential
+> integrity at runtime — cascade / restrict behavior applies.
 
 ## Schema
 
diff --git a/lib/app.rb b/lib/app.rb
index f72658a..4638176 100644
--- a/lib/app.rb
+++ b/lib/app.rb
@@ -9,7 +9,7 @@ module Domus
 
     def initialize(config = Config.env)
       @config = config
-      @db = Sequel.sqlite(config.database_url)
+      @db = Sequel.sqlite(config.database_url, foreign_keys: true)
     end
 
     def file_path(record)