Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add data migration to fix errant distribution+event #4619

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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