palkan / logidze

Database changes log for Rails
MIT License
1.6k stars 76 forks source link

Saving log with only metadata changes #241

Open whognu opened 1 year ago

whognu commented 1 year ago

Currently, Logidze seems to populate something to log_data only if there are changes to save on the model, but there are times that we'd like to save some metadata to log_data, without any changes being present in the model itself. I assume Logidze is tied into the model with a save callback or the like, so I'm not sure how practical this is, or if it risks a superfluous recursive call (or calls), but if it's workable, it would be better than having to put a dummy column on the model to change when we ant to trigger the log_data update.

palkan commented 1 year ago

assume Logidze is tied into the model with a save callback or the like

Logidze uses database triggers; so, there is no way to write metadata without touching the database record. The easiest way to achieve this is to call #touch on the record, no need to use a virtual model.