Sha256: e1de748d87d7db0422154c0b00c04777894ae8e3b9fc4d60c6a5645ea330509a

Contents?: true

Size: 447 Bytes

Versions: 27

Compression:

Stored size: 447 Bytes

Contents

class RemoveDuplicateServices < ActiveRecord::Migration
  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

27 entries across 27 versions & 1 rubygems

Version Path
metasploit_data_models-3.0.10 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-3.0.9 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-3.0.8 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-3.0.7 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-3.0.6 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-3.0.5 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-2.0.17 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-3.0.4 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-3.0.2 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-3.0.1 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-3.0.0 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-2.0.16 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-2.0.15 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-2.0.14 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-2.0.13 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-2.0.12 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-2.0.11 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-2.0.10 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-2.0.9 db/migrate/20150112203945_remove_duplicate_services.rb
metasploit_data_models-2.0.8 db/migrate/20150112203945_remove_duplicate_services.rb