Sha256: 507639f002e7864f74804df938b818330e300d22c51869cd439a2a5abf749eb4
Contents?: true
Size: 585 Bytes
Versions: 19
Compression:
Stored size: 585 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
19 entries across 19 versions & 3 rubygems