Sha256: ca3ed9675b1c4ad08aed8b18f83a90358d222f6e8f30be3a2fc9afe703cbd9da
Contents?: true
Size: 452 Bytes
Versions: 23
Compression:
Stored size: 452 Bytes
Contents
class RemoveDuplicateServices < 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
23 entries across 23 versions & 2 rubygems