Sha256: 504c7fda1df594be79b1cfd6f16cebe6fb84dc483d1095bdc1372ac8d2640df6

Contents?: true

Size: 682 Bytes

Versions: 5

Compression:

Stored size: 682 Bytes

Contents

# This migration comes from spree (originally 20140601011216)
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

5 entries across 5 versions & 3 rubygems

Version Path
sprangular-0.1.0 spec/dummy/db/migrate/20140814105773_set_shipment_total_for_users_upgrading.spree.rb
sprangular-0.0.1 spec/dummy/db/migrate/20140814105773_set_shipment_total_for_users_upgrading.spree.rb
spree_bitpay-1.0.2 spec/dummy/db/migrate/20141002181335_set_shipment_total_for_users_upgrading.spree.rb
bcms_spree-0.0.2 test/dummy/db/migrate/20140915222673_set_shipment_total_for_users_upgrading.spree.rb
bcms_spree-0.0.1 test/dummy/db/migrate/20140915222673_set_shipment_total_for_users_upgrading.spree.rb