palkan / logidze

Database changes log for Rails
MIT License
1.59k stars 74 forks source link

Add --after_trigger option #225

Closed SparLaimor closed 1 year ago

SparLaimor commented 1 year ago

What is the purpose of this pull request?

After trigger support #215

What changes did you make? (overview)

Add --after_trigger generator option.

Is there anything you'd like reviewers to focus on?

Updating with a partition change calls INSERT trigger, so we don't have access to the OLD record. In this case, we make a full snapshot (we can use previous versions to restore the state, but I'm not sure if that's a good idea).

I tried not to change the current integration tests and adapted them for both cases.

Checklist

palkan commented 1 year ago

Thanks for the PR!

Updating with a partition change calls INSERT trigger, so we don't have access to the OLD record. In this case, we make a full snapshot (we can use previous versions to restore the state, but I'm not sure if that's a good idea).

Thanks for pointing to this edge case. I think, creating a full snapshot is a viable option (we need to fill log_data with something).

I plan to combine this one and #226 on my own if you don't mind.

SparLaimor commented 1 year ago

@palkan, thanks. It will be good to select the best of the two solutions.

palkan commented 1 year ago

Opened #228, please take a look. It's based on your PR, though I changed the way the new logging function is generated.

Also, can you please provide your name, so I can add the information to Cult of Martians?

SparLaimor commented 1 year ago

@palkan Укажите меня как Андрей Телевной.