Thank everyone for te suggestions.
First point is that I really don’t want elixir to have the responsibility of writing the audits. If a record in a table changes because of action of an external system (or direct interaction through psql) I still want to audit the change.
I’m already doing the same for ids and timestamps. They are managed by the database in triggers.
So the only thing elixir has to do is to tell the database who is the “current responsible” of the changes.
I think that making an Ecto.Multi call hidden behind something like MyRepo.with_current_user(id_or_name) do ... end is the most likely solution. I just hope that all the team remember to always wrap any write in said block.
Or even tell the database to prevent any change unless the “current responsible” variable is set!!!


















