by kiwicopple · 2y ago · 0 comments
https://github.com/supabase/supa_audit
it uses a slightly more generic implementation so that you can easily turn on/off auditing. i.e.
select audit.enable_tracking('public.account'::regclass);
select audit.disable_tracking('public.account'::regclass);
the reason for the 'public.account'::regclass is to store the tables OID, rather than the name - this is cheaper than text and allows you to rename the table without losing the historyhttps://gist.github.com/cpursley/c8fb81fe8a7e5df038158bdfe0f...
I do a similar thing but add a foreign key columns for faster lookups (traversing using is slow on large sets when querying). The fk’s get set by the function itself during insert. This allows me to create per resource audit logs in the UI.
I also wrote some deep diff functions to get the changes between the old and new jsonb if anyone is interest. This makes it easy to display what exactly changed.
I'd love to see this if it's public
https://gist.github.com/cpursley/a2ae79423bee9274e3639839967...
Check the repo here https://github.com/grmkris/drizzle-pg-notify-audit-table
i'm not sure I follow - why would they avoid using non-JSON types?
more generally however: I don't have a lot of insight into the usage/feedback for this extension, but I can ask the team