Enable master variants with associated order cycles

There's only 5 in UK prod. keeping them is easier than figuring out if it's safe to delete.

(cherry picked from commit 4bf65e330b)
This commit is contained in:
David Cook
2023-06-23 11:50:26 +10:00
parent 4ac3dda398
commit fd889133cb

View File

@@ -5,6 +5,7 @@ class RemoveMasterVariants < ActiveRecord::Migration[7.0]
end
handle_master_line_items
handle_master_exchange_variants
delete_master_inventory_units
delete_master_variant_prices
delete_master_stock_items
@@ -24,6 +25,17 @@ class RemoveMasterVariants < ActiveRecord::Migration[7.0]
)
end
def handle_master_exchange_variants
ActiveRecord::Base.connection.execute(<<-SQL
UPDATE spree_variants
SET is_master = false
FROM exchange_variants
WHERE spree_variants.is_master = true
AND spree_variants.id = exchange_variants.variant_id
SQL
)
end
def delete_master_inventory_units
ActiveRecord::Base.connection.execute(<<-SQL
DELETE FROM spree_inventory_units