-
Notifications
You must be signed in to change notification settings - Fork 897
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove MiqQueue rows containing a class removed in Rails 5.
https://bugzilla.redhat.com/show_bug.cgi?id=1434454 The PostgreSQL::OID::Integer class was removed in: rails/rails@aafee23 It's possible that old Rails 4.2 versions of objects could have been serialized in the MiqQueue in the args column and we won't be able to deserialize them with Rails 5+, so we need to remove these rows. Related to #14365 Related to https://bugzilla.redhat.com/show_bug.cgi?id=1429747
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
db/migrate/20170320195659_remove_oid_integer_args_from_miq_queue.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class RemoveOidIntegerArgsFromMiqQueue < ActiveRecord::Migration[5.0] | ||
class MiqQueue < ActiveRecord::Base; end | ||
def up | ||
say_with_time("Removing MiqQueue rows with args column values containing a class removed from Rails 5: PostgreSQL::OID::Integer.") do | ||
MiqQueue.where("args LIKE '%PostgreSQL::OID::Integer%'").delete_all | ||
end | ||
end | ||
end |
27 changes: 27 additions & 0 deletions
27
spec/migrations/20170320195659_remove_oid_integer_args_from_miq_queue_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require_migration | ||
|
||
describe RemoveOidIntegerArgsFromMiqQueue do | ||
let(:queue_stub) { migration_stub(:MiqQueue) } | ||
|
||
migration_context :up do | ||
it 'deletes rows with PostgreSQL::OID:Integer class serialized in args' do | ||
args = <<-EOS | ||
--- | ||
- !ruby/object:ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Integer | ||
precision: | ||
scale: | ||
limit: 8 | ||
range: !ruby/range | ||
begin: -9223372036854775808 | ||
end: 9223372036854775808 | ||
excl: true | ||
EOS | ||
queue_stub.create(:state => "ready", :args => args) | ||
queue_stub.create(:state => "ready", :method_name => "stuff") | ||
migrate | ||
|
||
expect(queue_stub.count).to eq(1) | ||
expect(queue_stub.where(:method_name => "stuff").count).to eq(1) | ||
end | ||
end | ||
end |