Sha256: cf99122eca0667be54f49f3be5b37a43ab70aad6db44fa0bb9eb5839cd7c6bf9

Contents?: true

Size: 445 Bytes

Versions: 7

Compression:

Stored size: 445 Bytes

Contents

class RemoveAddressOrphans < ActiveRecord::Migration
  def self.up
    a_orphans = Address.all.reject do |a| 
                  Order.find_by_ship_address_id(a.id) or 
                  Order.find_by_bill_address_id(a.id) or 
                  Creditcard.find_by_address_id(a.id) or 
                  Shipment.find_by_address_id(a.id)
                end
    a_orphans.each {|a| a.destroy}
  end

  def self.down
    # nothing needed
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
kdmny-spree-0.0.1 db/migrate/20090525000325_remove_address_orphans.rb
spree-enriquez-0.9.4 db/migrate/20090525000325_remove_address_orphans.rb
spree-0.9.4 db/migrate/20090525000325_remove_address_orphans.rb
spree-0.9.3 db/migrate/20090525000325_remove_address_orphans.rb
spree-0.9.2 db/migrate/20090525000325_remove_address_orphans.rb
spree-0.9.1 db/migrate/20090525000325_remove_address_orphans.rb
spree-0.9.0 db/migrate/20090525000325_remove_address_orphans.rb