You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
resolves several foreign key constraint/cascade issues, primarily unblocking deletion of preparations:
- fix join table blocking deletion of preps with attached wallets
- fix mysql refusing to delete preprations due to fk cascade parallelogram (#465)
- fix postgres fk cascade deadlocks (same issue as above) with set null + trigger approach
this addresses the postgres-specific foreign key constraint violations
when deleting
preparations by implementing a database-level solution that:
1. makes files.attachment_id nullable
2. changes the fk constraint to ON DELETE SET NULL instead of
restrict/no action
3. adds a postgres trigger that immediately deletes files when
attachment_id becomes null
this approach keeps the application model unchanged (no pointer types)
while solving
the constraint violation. the trigger ensures the app never sees null
attachment_id
values so behavior stays consistent.
the solution is postgres-specific because:
- postgres has stricter fk enforcement that causes the
deadlock/violation issues
- mysql tests were already passing with the existing restrict behavior
- we removed cascade deletes in
640154e
to avoid deadlocks, but that created
the constraint violation when deleting preparations
longer term consideration: files conceptually belong to storages not
preparations.
attachments are just prep<->storage associations. we might want to
remove this fk
entirely since files should be storage-scoped and reusable across
preparations
(expensive to re-scan). this would eliminate the cascade issues entirely
while
enabling file reuse when recreating preparations with the same storage.
this resolves two issues that prevent deletion of preparations. fixes#465
0 commit comments