From e3c488306cac6332c78231046cc81e2e1c35cff6 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 15 Jul 2023 15:55:05 +0100 Subject: [PATCH] Migrate data for shipping_category_id --- .../20230715145329_migrate_shipping_category.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 db/migrate/20230715145329_migrate_shipping_category.rb diff --git a/db/migrate/20230715145329_migrate_shipping_category.rb b/db/migrate/20230715145329_migrate_shipping_category.rb new file mode 100644 index 0000000000..9b8d970cae --- /dev/null +++ b/db/migrate/20230715145329_migrate_shipping_category.rb @@ -0,0 +1,15 @@ +class MigrateShippingCategory < ActiveRecord::Migration[7.0] + def up + migrate_shipping_category + end + + def migrate_shipping_category + ActiveRecord::Base.connection.execute(<<-SQL + UPDATE spree_variants + SET shipping_category_id = spree_products.shipping_category_id + FROM spree_products + WHERE spree_variants.product_id = spree_products.id + SQL + ) + end +end