Skip to content

Commit

Permalink
Merge pull request #4619 from rubyforgood/fix-bad-event
Browse files Browse the repository at this point in the history
Add data migration to fix errant distribution+event
  • Loading branch information
awwaiid committed Aug 30, 2024
2 parents 15f51d5 + 5800bf9 commit cbdce9b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions db/migrate/20240830015517_fix_invalid_distribution_event.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class FixInvalidDistributionEvent < ActiveRecord::Migration[7.1]
def change
return unless Rails.env.production?

# We are not sure why yet, but this org was able to create a distribution
# that put them at a negative inventory. Later playback of the events with
# validation turned on then raised it as an error. For now we are deleting
# the distribution and event directly.
Event.where(id: 34416, eventable_type: 'Distribution', eventable_id: 75002).first.destroy
Distribution.find(75002).destroy
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2024_07_18_010905) do
ActiveRecord::Schema[7.1].define(version: 2024_08_30_015517) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Expand Down

0 comments on commit cbdce9b

Please sign in to comment.