hair_trigger icon indicating copy to clipboard operation
hair_trigger copied to clipboard

Rails 8 migration issue, duplicate before(:update)

Open chabgood opened this issue 9 months ago • 1 comments

I have this in my model: trigger.before(:insert).before(:update) do

When I generated the migration I got this: create_trigger("exercises_before_update_row_tr", :generated => true, :compatibility => 1). on("exercises"). before(:update). before(:update) do

chabgood avatar Mar 27 '25 19:03 chabgood

HairTrigger currently expects each method to be called at most once, so you can work around this be changing your to this:

trigger.before(:insert, :update) do

That said, ideally HairTrigger should either 1. handle multiple calls or 2. throw an error in this case, since the current behavior is not ideal. So we can keep this issue open until that's resolved, PRs are welcome!

jenseng avatar Mar 31 '25 15:03 jenseng