20131121162641_remove_orphan_profiles.rb 305 Bytes
class RemoveOrphanProfiles < ActiveRecord::Migration
  def self.up
    profiles = Profile.joins('LEFT JOIN environments ON profiles.environment_id=environments.id').where('environments.id IS NULL')
    profiles.map(&:destroy)
  end

  def self.down
    say 'This migration can not be reverted.'
  end
end