Skip to content

Commit

Permalink
found in prod an example of a se with no tries
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Jan 20, 2024
1 parent 410fbff commit ee27bc5
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
class EnsureOwnerIdForSearchEndpoints < ActiveRecord::Migration[7.1]
def change

def change
# Discoverd that there are search endpoints being created without an owner!

puts "Found #{SearchEndpoint.all.where(owner_id: nil).count} search endpoints missing owner"

SearchEndpoint.all.where(owner_id: nil).each do |se|
se.owner = se.tries.last.case.owner
# only do this where we have a try related...
if se.tries.last
se.owner = se.tries.last.case.owner
end
se.save!
end
end
Expand Down

0 comments on commit ee27bc5

Please sign in to comment.