diff --git a/db/migrate/20230605133804_remove_master_variants.rb b/db/migrate/20230605133804_remove_master_variants.rb index 84477199f4..149edcbbcf 100644 --- a/db/migrate/20230605133804_remove_master_variants.rb +++ b/db/migrate/20230605133804_remove_master_variants.rb @@ -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