mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Reset negative count on hand in existing non backorderable stock items
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ResetNegativeNonbackorderableCountOnHandInStockItems < ActiveRecord::Migration
|
||||
module Spree
|
||||
class StockItem < ActiveRecord::Base
|
||||
self.table_name = "spree_stock_items"
|
||||
end
|
||||
end
|
||||
|
||||
def up
|
||||
Spree::StockItem.where(backorderable: false)
|
||||
.where("count_on_hand < 0")
|
||||
.update_all(count_on_hand: 0)
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user