Sha256: d898c48c4aa9888345864284509c29445f6864a894aa9f5dced90d9c0b801153

Contents?: true

Size: 620 Bytes

Versions: 11

Compression:

Stored size: 620 Bytes

Contents

class SetShipmentTotalForUsersUpgrading < ActiveRecord::Migration
  def up
    # NOTE You might not need this at all unless you're upgrading from Spree 2.1.x
    # or below. For those upgrading this should populate the Order#shipment_total
    # for legacy orders
    execute "UPDATE spree_orders
             SET shipment_total = (SELECT SUM(spree_shipments.cost) AS sum_id
                                   FROM spree_shipments
                                   WHERE spree_shipments.order_id = spree_orders.id)
             WHERE spree_orders.completed_at IS NOT NULL AND spree_orders.shipment_total = 0"
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
spree_core-2.4.0.rc2 db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb
spree_core-2.4.0.rc1 db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb
spree_core-2.3.4 db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb
spree_core-2.2.6 db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb
spree_core-2.3.3 db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb
spree_core-2.3.2 db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb
spree_core-2.2.5 db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb
spree_core-2.3.1 db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb
spree_core-2.2.4 db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb
spree_core-2.2.3 db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb
spree_core-2.3.0 db/migrate/20140601011216_set_shipment_total_for_users_upgrading.rb