Sha256: 84acc2b648e48dff7bc5762202dba5f561868a73673c22ac9b38ad674ad07d93

Contents?: true

Size: 453 Bytes

Versions: 22

Compression:

Stored size: 453 Bytes

Contents

class RemoveDuplicateServices2 < ActiveRecord::Migration[4.2]
  def change
    select_mgr = Mdm::Service.arel_table.project(
      Mdm::Service[:host_id],
      Mdm::Service[:proto],
      Mdm::Service[:port].count
    ).group(
      'host_id',
      'port',
      'proto'
    ).having(Mdm::Service[:port].count.gt(1))

    Mdm::Service.find_by_sql(select_mgr).each(&:destroy)

    add_index :services, [:host_id, :port, :proto], unique: true
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
wg-metasploit_data_models-4.1.4.02 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-6.0.5 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-6.0.4 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-6.0.3 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-6.0.2 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-6.0.1 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-6.0.0 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-5.0.6 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-5.0.5 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-5.0.4 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-5.0.3 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-5.0.2 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-5.0.1 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-5.0.0 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-4.1.4 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-4.1.3 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-4.1.2 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-4.1.1 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-4.1.0 db/migrate/20150212214222_remove_duplicate_services2.rb
metasploit_data_models-4.0.2 db/migrate/20150212214222_remove_duplicate_services2.rb