Skip to content

Commit

Permalink
Merge pull request #496 from agrare/delete_worker_records_with_json_q…
Browse files Browse the repository at this point in the history
…ueue_names

Delete any worker records that have a JSON queue_name
  • Loading branch information
Fryguy authored Oct 2, 2020
2 parents 57d10b7 + 0c95def commit 9ef5d38
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
11 changes: 11 additions & 0 deletions db/migrate/20200717181436_delete_workers_with_json_queue_names.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class DeleteWorkersWithJsonQueueNames < ActiveRecord::Migration[5.2]
class MiqWorker < ActiveRecord::Base
include ActiveRecord::IdRegions

self.inheritance_column = :_type_disabled
end

def up
MiqWorker.in_my_region.where("queue_name LIKE ?", "\[%\]").delete_all
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require_migration

describe DeleteWorkersWithJsonQueueNames do
let(:miq_worker_stub) { migration_stub(:MiqWorker) }

migration_context :up do
it "deletes workers with a JSON type queue name" do
worker = miq_worker_stub.create!(:queue_name => "[\"ems_4\", \"ems_5\", \"ems_6\"]")

migrate

expect(miq_worker_stub.find_by(:id => worker.id)).to be_nil
end

it "doesn't touch workers without JSON queue names" do
worker = miq_worker_stub.create!(:queue_name => "ems_1")

migrate

expect(worker.reload.queue_name).to eq("ems_1")
end
end
end

0 comments on commit 9ef5d38

Please sign in to comment.