diff --git a/db/migrate/20240830015517_fix_invalid_distribution_event.rb b/db/migrate/20240830015517_fix_invalid_distribution_event.rb new file mode 100644 index 0000000000..cace57fead --- /dev/null +++ b/db/migrate/20240830015517_fix_invalid_distribution_event.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index bcc773347a..91483f028f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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"