From 4c5ecbc2d4d4eae46ca4c9365d948ef8e6998263 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Fri, 19 Mar 2021 16:02:57 +0000 Subject: [PATCH] Migrate return adjustments source to originator --- .../20210319155627_update_return_adjustments.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 db/migrate/20210319155627_update_return_adjustments.rb diff --git a/db/migrate/20210319155627_update_return_adjustments.rb b/db/migrate/20210319155627_update_return_adjustments.rb new file mode 100644 index 0000000000..cd6a9788c6 --- /dev/null +++ b/db/migrate/20210319155627_update_return_adjustments.rb @@ -0,0 +1,17 @@ +class UpdateReturnAdjustments < ActiveRecord::Migration[5.0] + class Spree::Adjustment < ActiveRecord::Base + belongs_to :source, polymorphic: true + end + + def up + Spree::Adjustment.where(source_type: 'Spree::ReturnAuthorization').update_all( + "originator_id = source_id, originator_type = 'Spree::ReturnAuthorization', source_id = NULL, source_type = NULL" + ) + end + + def down + Spree::Adjustment.where(originator_type: 'Spree::ReturnAuthorization').update_all( + "source_id = originator_id, source_type = 'Spree::ReturnAuthorization', originator_id = NULL, originator_type = NULL" + ) + end +end