Sha256: 546f65ea7590fa9d0524515967b82d93278699a09b4ebaeb7ddc0469f42947c7

Contents?: true

Size: 577 Bytes

Versions: 45

Compression:

Stored size: 577 Bytes

Contents

class ShipmentIdForInventoryUnits < ActiveRecord::Migration
  def self.up
    add_column "inventory_units", "shipment_id", :integer
    add_index(:inventory_units, :shipment_id)

    # migrate legacy shipments
    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_attribute("shipment_id", shipment.id)
      end
    end
  end

  def self.down
    remove_column "inventory_units", "shipment_id"
  end
end

Version data entries

45 entries across 33 versions & 8 rubygems

Version Path
spree_core-0.70.7 db/migrate/20100105132138_shipment_id_for_inventory_units.rb
spree_core-0.70.6 db/migrate/20100105132138_shipment_id_for_inventory_units.rb
apispree_core-0.0.0 db/migrate/20100105132138_shipment_id_for_inventory_units.rb
My-Commerce_core-1.1.0 db/migrate/20100105132138_shipment_id_for_inventory_units.rb
My-Commerce_core-1.0.0 db/migrate/20100105132138_shipment_id_for_inventory_units.rb
MyCommerceapi-1.0.0 core/spec/test_app/db/migrate/20100105132138_shipment_id_for_inventory_units.rb
MyCommerceapi-1.0.0 dash/spec/test_app/db/migrate/20100105132138_shipment_id_for_inventory_units.rb
MyCommerceapi-1.0.0 api/spec/test_app/db/migrate/20100105132138_shipment_id_for_inventory_units.rb
MyCommerceapi-1.0.0 sandbox/db/migrate/20100105132138_shipment_id_for_inventory_units.rb
MyCommerceapi-1.0.0 auth/spec/test_app/db/migrate/20100105132138_shipment_id_for_inventory_units.rb
MyCommerceapi-1.0.0 core/db/migrate/20100105132138_shipment_id_for_inventory_units.rb
MyCommerceapi-1.0.0 promo/spec/test_app/db/migrate/20100105132138_shipment_id_for_inventory_units.rb
MyCommerce-0.0.3 sandbox/db/migrate/20100105132138_shipment_id_for_inventory_units.rb
MyCommerce-0.0.3 api/spec/test_app/db/migrate/20100105132138_shipment_id_for_inventory_units.rb
MyCommerce-0.0.3 auth/spec/test_app/db/migrate/20100105132138_shipment_id_for_inventory_units.rb
MyCommerce-0.0.3 core/spec/test_app/db/migrate/20100105132138_shipment_id_for_inventory_units.rb
MyCommerce-0.0.3 dash/spec/test_app/db/migrate/20100105132138_shipment_id_for_inventory_units.rb
MyCommerce-0.0.3 promo/spec/test_app/db/migrate/20100105132138_shipment_id_for_inventory_units.rb
MyCommerce-0.0.3 core/db/migrate/20100105132138_shipment_id_for_inventory_units.rb
rfcommerce_sandbox-0.0.3 db/migrate/20100105132138_shipment_id_for_inventory_units.rb