mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
Update any adjustments that are missing an order association
This commit is contained in:
13
db/migrate/20210315163900_update_associations.rb
Normal file
13
db/migrate/20210315163900_update_associations.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class UpdateAssociations < ActiveRecord::Migration[5.0]
|
||||
class Spree::Adjustment < ActiveRecord::Base
|
||||
belongs_to :adjustable, polymorphic: true
|
||||
belongs_to :order, class_name: "Spree::Order"
|
||||
end
|
||||
|
||||
def up
|
||||
# Updates any adjustments missing an order association
|
||||
Spree::Adjustment.where(order_id: nil, adjustable_type: "Spree::Order").find_each do |adjustment|
|
||||
adjustment.update_column(:order_id, adjustment.adjustable_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20210312095840) do
|
||||
ActiveRecord::Schema.define(version: 20210315163900) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
Reference in New Issue
Block a user