Migrate return adjustments source to originator

This commit is contained in:
Matt-Yorkley
2021-03-19 16:02:57 +00:00
parent 3c1883dac2
commit 4c5ecbc2d4

View File

@@ -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