Add fix for counter_cache migration to keep from throwing readonly column error.
parent
ced5b9916e
commit
315d68b6f5
|
@ -1,4 +1,5 @@
|
|||
class AddCounterCachesToHosts < ActiveRecord::Migration
|
||||
|
||||
def self.up
|
||||
add_column :hosts, :note_count, :integer, :default => 0
|
||||
add_column :hosts, :vuln_count, :integer, :default => 0
|
||||
|
@ -6,9 +7,9 @@ class AddCounterCachesToHosts < ActiveRecord::Migration
|
|||
|
||||
Mdm::Host.reset_column_information
|
||||
Mdm::Host.all.each do |h|
|
||||
h.update_attribute :note_count, h.notes.length
|
||||
h.update_attribute :vuln_count, h.vulns.length
|
||||
h.update_attribute :service_count, h.services.length
|
||||
Mdm::Host.reset_counters h.id, :notes
|
||||
Mdm::Host.reset_counters h.id, :vulns
|
||||
Mdm::Host.reset_counters h.id, :services
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue