Re: Before image of selective columns. - Mailing list pgsql-admin

From Ron Johnson
Subject Re: Before image of selective columns.
Date
Msg-id CANzqJaCUTtUH44C6FJDXJ2ZwFFWjMCQz-pV_QmnVVaUJUhuAhw@mail.gmail.com
Whole thread Raw
In response to Re: Before image of selective columns.  (Scott Ribe <scott_ribe@elevated-dev.com>)
List pgsql-admin
On Fri, Jan 10, 2025 at 8:41 AM Scott Ribe <scott_ribe@elevated-dev.com> wrote:
> On Jan 10, 2025, at 2:55 AM, Laurenz Albe <laurenz.albe@cybertec.at> wrote:
>
> That looks like a job for a trigger; perhaps a statement level trigger
> with a transition table.

Indeed.

I just want to add from experience: put the row values into a JSON column in the audit table. Otherwise, what do you do when the table definition changes? It's not just that you would have to keep the audit table schema in sync, it's possible to have a change which is not compatible with the old definition, such that you now really can't have one table that covers both old and new exactly, and then have to resort to renaming columns or some such...

For years, we've used triggers to populate such tables, but never had incompatibility problems.  Mainly because we add new columns and upsize existing columns to compatible types.

Everyone's situation is different, though.

--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!

pgsql-admin by date:

Previous
From: Scott Ribe
Date:
Subject: Re: Before image of selective columns.
Next
From: kasem adel
Date:
Subject: Archiving solutions