Skip to content

Commit

Permalink
add rescue when failing to update charge filters and charges (#3103)
Browse files Browse the repository at this point in the history
## Context

When an organization have charges or charge filters with wrong
properties, the migration fails and it's hard to indicate what exactly
went wrong

## Description

Added rescue to migration that fixes double properties for charges and
charges filters
  • Loading branch information
annvelents authored Jan 24, 2025
1 parent 3881346 commit 4bbb63b
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ def fix_charge_filter_properties(charge_filter)
).raise_if_error!
charge_filter.properties = result.properties
charge_filter.save!
rescue ActiveRecord::RecordInvalid => e
say '-' * 50
say e.message
say "Please fix the following charge filter manually:"
say "Failed charge_filter_id: #{charge_filter.id}"
say "Charge Filter properties: #{charge_filter.properties}"
say "Charge payment model: #{charge_filter.charge.charge_model}"
end

def fix_charge_properties(charge)
Expand All @@ -32,5 +39,12 @@ def fix_charge_properties(charge)
).raise_if_error!
charge.properties = result.properties
charge.save!
rescue ActiveRecord::RecordInvalid => e
say '-' * 50
say e.message
say "Please fix the following charge manually:"
say "Failed charge_id: #{charge.id}"
say "Charge properties: #{charge.properties}"
say "Charge payment model: #{charge.charge_model}"
end
end

0 comments on commit 4bbb63b

Please sign in to comment.