diff --git a/db/migrate/20190906151259_reset_negative_stock_levels.rb b/db/migrate/20190906151259_reset_negative_stock_levels.rb new file mode 100644 index 0000000000..ec0be5a4be --- /dev/null +++ b/db/migrate/20190906151259_reset_negative_stock_levels.rb @@ -0,0 +1,6 @@ +class ResetNegativeStockLevels < ActiveRecord::Migration + def up + # Reset stock to zero for all on_demand variants that have negative stock + execute "UPDATE spree_stock_items SET count_on_hand = '0' WHERE count_on_hand < 0 AND backorderable IS TRUE" + end +end