1 class AddCounterCaches < ActiveRecord::Migration
3 add_column :users, :changesets_count, :integer, :null => false, :default => 0
4 add_column :users, :traces_count, :integer, :null => false, :default => 0
6 Changeset.group(:user_id).pluck(:user_id).each do |user_id|
7 User.reset_counters(user_id, :changesets)
10 Trace.group(:user_id).pluck(:user_id).each do |user_id|
11 User.reset_counters(user_id, :traces)
16 remove_column :users, :changesets_count
17 remove_column :users, :traces_count