Add counts to edits, blocks, and traces; don't show blocks if there are none; and move OAuth to the settings page.
19 lines
574 B
Ruby
19 lines
574 B
Ruby
class AddCounterCaches < ActiveRecord::Migration
|
|
def self.up
|
|
add_column :users, :changesets_count, :integer, :null => false, :default => 0
|
|
add_column :users, :traces_count, :integer, :null => false, :default => 0
|
|
|
|
Changeset.group(:user_id).pluck(:user_id).each do |user_id|
|
|
User.reset_counters(user_id, :changesets)
|
|
end
|
|
|
|
Trace.group(:user_id).pluck(:user_id).each do |user_id|
|
|
User.reset_counters(user_id, :traces)
|
|
end
|
|
end
|
|
|
|
def self.down
|
|
remove_column :users, :changesets_count
|
|
remove_column :users, :traces_count
|
|
end
|
|
end
|