From 4bf65e330bd0e29cf1f52dd64b3c7e31f74e61a7 Mon Sep 17 00:00:00 2001 From: David Cook Date: Fri, 23 Jun 2023 11:50:26 +1000 Subject: [PATCH] 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. --- db/migrate/20230605133804_remove_master_variants.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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