Class: AddCounterCachesToHosts
- Inherits:
-
ActiveRecord::Migration
- Object
- ActiveRecord::Migration
- AddCounterCachesToHosts
- Defined in:
- db/migrate/20120601152442_add_counter_caches_to_hosts.rb
Class Method Summary collapse
Class Method Details
.down ⇒ Object
16 17 18 19 20 |
# File 'db/migrate/20120601152442_add_counter_caches_to_hosts.rb', line 16 def self.down remove_column :hosts, :note_count remove_column :hosts, :vuln_count remove_column :hosts, :service_count end |
.up ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'db/migrate/20120601152442_add_counter_caches_to_hosts.rb', line 3 def self.up add_column :hosts, :note_count, :integer, :default => 0 add_column :hosts, :vuln_count, :integer, :default => 0 add_column :hosts, :service_count, :integer, :default => 0 Mdm::Host.reset_column_information Mdm::Host.all.each do |h| Mdm::Host.reset_counters h.id, :notes Mdm::Host.reset_counters h.id, :vulns Mdm::Host.reset_counters h.id, :services end end |