fix(db): enable SQLite foreign_keys explicitly (audit 6c-9)
SQLite defaults foreign_keys OFF per connection, and the schema relies on ON DELETE CASCADE (entry_attachments, entries_password_history, recovery_keys). FireDAC is said to default it On but that's undocumented here — set ForeignKeys=On so a permanent delete never orphans encrypted blobs. Correct in both cases (no-op if already On). Base check before fix: 0 orphans. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -83,6 +83,12 @@ begin
|
||||
FConn.Params.Values['Synchronous'] := 'Normal';
|
||||
FConn.Params.Values['BusyTimeout'] := '5000';
|
||||
FConn.Params.Values['JournalMode'] := 'WAL';
|
||||
// Explicit ON: SQLite defaults foreign_keys OFF per-connection, and the
|
||||
// schema relies on ON DELETE CASCADE (entry_attachments, entries_password_
|
||||
// history, recovery_keys on user/entry delete). FireDAC is *said* to default
|
||||
// this On but it's undocumented for us — set it so a permanent delete never
|
||||
// leaves orphaned encrypted blobs. No-op if it was already On (§6c-9).
|
||||
FConn.Params.Values['ForeignKeys'] := 'On';
|
||||
FConn.Open;
|
||||
CreateSchema;
|
||||
ApplyMigrations;
|
||||
|
||||
Reference in New Issue
Block a user