~/talk

Using database triggers to reliably track model history

Talkat DjangoCon US 2023 · 2023-10-16..10-20· [databases, python]
slides:none on file

Proposes using Postgres triggers plus django-pghistory to create structured per-model event tables that snapshot every INSERT/UPDATE so bulk ops and raw SQL never miss an audit row, with optional immutability to prevent tampering. Shows trigger installation via PG triggers, a context manager that attaches request/user metadata, a revert API to restore prior states, and a soft-delete pattern that stores deletions in a separate history table — all claimed to run reliably and performantly.

AI-written summary · about

  1. 0:00Database trigger history intro
  2. 3:08Traditional history tracking flaws
  3. 6:39Django-PG-History internals
  4. 9:46Why database triggers matter
  5. 12:11Trigger-based history benefits
  6. 15:44User/request metadata tracking
  7. 19:35Advanced design patterns
  8. 20:18Default context with middleware
  9. 22:22Celery task context tracking
  10. 24:07Reverting models
  11. 26:35Soft delete with triggers
  12. 31:06Foreign keys to events
  13. 33:32App-specific event logs
  14. 35:17Overdraft alerts tracking
  15. 37:23Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.