mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-09 23:06:06 +00:00
Delete stock_items for master variants
All variants have stock_items records, but master variants never use them, so these were always redundant.
This commit is contained in:
@@ -7,6 +7,7 @@ class RemoveMasterVariants < ActiveRecord::Migration[7.0]
|
||||
handle_master_line_items
|
||||
delete_master_inventory_units
|
||||
delete_master_variant_prices
|
||||
delete_master_stock_items
|
||||
delete_master_variants
|
||||
end
|
||||
|
||||
@@ -53,6 +54,16 @@ class RemoveMasterVariants < ActiveRecord::Migration[7.0]
|
||||
)
|
||||
end
|
||||
|
||||
def delete_master_stock_items
|
||||
ActiveRecord::Base.connection.execute(<<-SQL
|
||||
DELETE FROM spree_stock_items
|
||||
USING spree_variants
|
||||
WHERE spree_variants.is_master = true
|
||||
AND spree_variants.id = spree_stock_items.variant_id
|
||||
SQL
|
||||
)
|
||||
end
|
||||
|
||||
def delete_master_variants
|
||||
ActiveRecord::Base.connection.execute(<<-SQL
|
||||
DELETE FROM spree_variants
|
||||
|
||||
Reference in New Issue
Block a user