Sha256: dc46c77fac77587ce106948224e9365736334f1da7647d9625d47055e16c52f4

Contents?: true

Size: 664 Bytes

Versions: 11

Compression:

Stored size: 664 Bytes

Contents

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

11 entries across 11 versions & 1 rubygems

Version Path
spree_core-1.2.5 db/migrate/20100105132138_shipment_id_for_inventory_units.rb
spree_core-1.1.6 db/migrate/20100105132138_shipment_id_for_inventory_units.rb
spree_core-1.1.5 db/migrate/20100105132138_shipment_id_for_inventory_units.rb
spree_core-1.2.4 db/migrate/20100105132138_shipment_id_for_inventory_units.rb
spree_core-1.2.3 db/migrate/20100105132138_shipment_id_for_inventory_units.rb
spree_core-1.2.2 db/migrate/20100105132138_shipment_id_for_inventory_units.rb
spree_core-1.1.4 db/migrate/20100105132138_shipment_id_for_inventory_units.rb
spree_core-1.2.0 db/migrate/20100105132138_shipment_id_for_inventory_units.rb
spree_core-1.2.0.rc2 db/migrate/20100105132138_shipment_id_for_inventory_units.rb
spree_core-1.2.0.rc1 db/migrate/20100105132138_shipment_id_for_inventory_units.rb
spree_core-1.1.3 db/migrate/20100105132138_shipment_id_for_inventory_units.rb