```ruby
SnifferPlugin.send :remove_const, :Opportunity

class SnifferPlugin::Profile < Noosfero::Plugin::ActiveRecord
  belongs_to :profile
end
class SnifferPlugin::Opportunity < Noosfero::Plugin::ActiveRecord
  belongs_to :sniffer_profile, :class_name => 'SnifferPlugin::Profile', :foreign_key => :profile_id
end

class DropSnifferProfileTable < ActiveRecord::Migration
  def self.up
    SnifferPlugin::Opportunity.find_each do |opportunity|
      sniffer_profile = opportunity.sniffer_profile
      next unless sniffer_profile.profile

      opportunity.profile_id = sniffer_profile.profile.id
      opportunity.save!
    end

    drop_table :sniffer_plugin_profiles
  end

  def self.down
  end
end
```

Add check to avoid crash
user
```ruby
SnifferPlugin.send :remove_const, :Opportunity if defined? SnifferPlugin::Opportunity

class SnifferPlugin::Profile < Noosfero::Plugin::ActiveRecord
  belongs_to :profile
end
class SnifferPlugin::Opportunity < Noosfero::Plugin::ActiveRecord
  belongs_to :sniffer_profile, :class_name => 'SnifferPlugin::Profile', :foreign_key => :profile_id
end

class DropSnifferProfileTable < ActiveRecord::Migration
  def self.up
    SnifferPlugin::Opportunity.find_each do |opportunity|
      sniffer_profile = opportunity.sniffer_profile
      next unless sniffer_profile.profile

      opportunity.profile_id = sniffer_profile.profile.id
      opportunity.save!
    end

    drop_table :sniffer_plugin_profiles
  end

  def self.down
  end
end
```
assistant