Skip to content

Commit

Permalink
delete old default search from db if it is not supplied anymore
Browse files Browse the repository at this point in the history
There is no easy way to correct typo in the name of search
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1740309
  • Loading branch information
yrudman committed Aug 14, 2019
1 parent 2d4891d commit d18e09f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/models/miq_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ def self.seed
name = attrs['name']
db = attrs['db']

rec = searches["#{name}-#{db}"]
rec = searches.delete("#{name}-#{db}")
if rec.nil?
_log.info("Creating [#{name}]")
searches["#{name}-#{db}"] = create!(attrs)
create!(attrs)
else
# Avoid undoing user changes made to enable/disable default searches which is held in the search_key column
attrs.delete('search_key')
Expand All @@ -109,6 +109,10 @@ def self.seed
rec.save! if rec.changed?
end
end
if searches.any?
_log.warn("Deleting the following MiqSearch(es) as they no longer exist: #{searches.keys.sort.collect(&:inspect).join(", ")}")
MiqSearch.destroy(searches.values.map(&:id))
end
end

def self.display_name(number = 1)
Expand Down

0 comments on commit d18e09f

Please sign in to comment.