Revision ff1e9ffc
Added by Dominic Cleal over 6 years ago
db/migrate/20150819105725_add_lookup_value_match_to_host_and_hostgroup.rb | ||
---|---|---|
Host::Managed.reset_column_information
|
||
Hostgroup.reset_column_information
|
||
|
||
matchers = LookupValue.where("lookup_values.match like ?", "fqdn=%").uniq.pluck('lookup_values.match')
|
||
matchers = LookupValue.where("lookup_values.match like ?", "fqdn=%").distinct.pluck('lookup_values.match')
|
||
fqdns = matchers.map{|m| m.gsub(/^fqdn=/, "")}
|
||
hostnames = fqdns.map{|fqdn| fqdn.split(".").first}
|
||
|
||
... | ... | |
end
|
||
|
||
if hosts.present?
|
||
hosts = hosts.readonly(false).uniq
|
||
hosts = hosts.readonly(false).distinct
|
||
|
||
hosts.each do |host|
|
||
host.update_attribute(:lookup_value_matcher, host.send(:lookup_value_match))
|
Also available in: Unified diff
Fixes #20950 - Use 'distinct' in AR finders