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