fix(data): harden FK pragma per-connection and seed concurrency
- Add SqliteForeignKeyInterceptor (DbConnectionInterceptor) registered via OnConfiguring so every IDbContextFactory-created context runs PRAGMA foreign_keys=ON, not only the MigrateAndConfigure context. - DefaultListsSeeder: replace TOCTOU read-then-insert with atomic INSERT … SELECT … WHERE NOT EXISTS — one SQLite writer lock, no race. - AppSettingsRepository.GetAsync: catch DbUpdateException on the get-or-create path and re-read so concurrent startup cannot throw. - Migration 20260609000000_UniqueListName: de-duplicates empty list rows (startup-race leftovers) then adds a UNIQUE index on lists.name. - ForeignKeyTests: verifies ON DELETE SET NULL (blocked_by_task_id) is enforced on a fresh DbContext with no manual PRAGMA call. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -211,6 +211,10 @@ namespace ClaudeDo.Data.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Name")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx_lists_name");
|
||||
|
||||
b.HasIndex("SortOrder")
|
||||
.HasDatabaseName("idx_lists_sort");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user