1 class AddCounterCaches < ActiveRecord::Migration[4.2]
2 class Changeset < ActiveRecord::Base
5 class Trace < ActiveRecord::Base
6 self.table_name = "gpx_files"
10 add_column :users, :changesets_count, :integer, :null => false, :default => 0
11 add_column :users, :traces_count, :integer, :null => false, :default => 0
13 Changeset.group(:user_id).pluck(:user_id).each do |user_id|
14 User.reset_counters(user_id, :changesets)
17 Trace.group(:user_id).pluck(:user_id).each do |user_id|
18 User.reset_counters(user_id, :traces)
23 remove_column :users, :changesets_count
24 remove_column :users, :traces_count