Sha256: b692a112d9ecbcefa7b53fd9e2e54e5900a92e4d8d5b7598671780be3fab0fa7
Contents?: true
Size: 698 Bytes
Versions: 151
Compression:
Stored size: 698 Bytes
Contents
class AddCredsCounterCache < ActiveRecord::Migration def up add_column :hosts, :cred_count, :integer, :default => 0 Mdm::Host.reset_column_information # Set initial counts cred_service_ids = Set.new Mdm::Cred.all.each {|c| cred_service_ids << c.service_id} cred_service_ids.each do |service_id| #Mdm::Host.reset_counters(Mdm::Service.find(service_id).host.id, :creds) begin host = Mdm::Service.find(service_id).host rescue next end next if host.nil? # This can happen with orphan creds/services host.cred_count = host.creds.count host.save end end def down remove_column :hosts, :cred_count end end
Version data entries
151 entries across 151 versions & 1 rubygems