Sha256: be95270401e7f5c80475270c434f5d8ec63c381cfb58fbe9b46532929a9eb2c9

Contents?: true

Size: 726 Bytes

Versions: 7

Compression:

Stored size: 726 Bytes

Contents

# This migration comes from spree (originally 20100105132138)
class ShipmentIdForInventoryUnits < ActiveRecord::Migration
  def up
    add_column :inventory_units, :shipment_id, :integer
    add_index :inventory_units, :shipment_id

    # migrate legacy shipments
    Spree::Shipment.table_name = 'shipments'

    Spree::Shipment.all.each do |shipment|
      unless shipment.order
        puts "Warning: shipment has invalid order - #{shipment.id}"
        next
      end
      shipment.order.inventory_units.each do |unit|
        unit.update_column('shipment_id', shipment.id)
      end
    end

    Spree::Shipment.table_name = 'spree_shipments'
  end

  def down
    remove_column :inventory_units, :shipment_id
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
spree_mercado_pago_payment_method-0.0.2 spec/dummy/db/migrate/20121121030159_shipment_id_for_inventory_units.spree.rb
spree_mercado_pago_payment_method-0.1.1 spec/dummy/db/migrate/20121121030159_shipment_id_for_inventory_units.spree.rb
spree_mercado_pago_payment_method-0.1.0 spec/dummy/db/migrate/20121121030159_shipment_id_for_inventory_units.spree.rb
datashift_spree-0.3.0 spec/sandbox/db/migrate/20121023154378_shipment_id_for_inventory_units.spree.rb
datashift_spree-0.2.1 spec/sandbox/db/migrate/20121015151171_shipment_id_for_inventory_units.spree.rb
datashift_spree-0.2.0 spec/sandbox/db/migrate/20120925192739_shipment_id_for_inventory_units.spree.rb
datashift_spree-0.1.0 spec/sandbox/db/migrate/20120918081470_shipment_id_for_inventory_units.spree.rb