Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

if `user_id` is in the table you're auditing you could do

``` alter table audit.record_version add column user_id bigint default (coalesce(record, old_record) ->> 'user_id'); ```

or if you meant the SQL `current_user` you could extend the trigger to track it.

but if the user_id is only available in application space (not in the db) it will not be possible using straight SQL



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: