```ruby
class AddCachedVotesToQuestions < ActiveRecord::Migration
  def self.up
    add_column :questions, :cached_votes_total, :integer, :default => 0
    add_column :questions, :cached_votes_score, :integer, :default => 0
    add_column :questions, :cached_votes_up, :integer, :default => 0
    add_column :questions, :cached_votes_down, :integer, :default => 0
    add_column :questions, :cached_weighted_score, :integer, :default => 0
    add_column :questions, :cached_weighted_total, :integer, :default => 0
    add_column :questions, :cached_weighted_average, :float, :default => 0.0
    add_index  :questions, :cached_votes_total
    add_index  :questions, :cached_votes_score
    add_index  :questions, :cached_votes_up
    add_index  :questions, :cached_votes_down
    add_index  :questions, :cached_weighted_score
    add_index  :questions, :cached_weighted_total
    add_index  :questions, :cached_weighted_average

    # Uncomment this line to force caching of existing votes
    Post.find_each(&:update_cached_votes)
  end
end
```

Change 'Post' to 'Question' in cached_votes migration
user
```ruby
class AddCachedVotesToQuestions < ActiveRecord::Migration
  def self.up
    add_column :questions, :cached_votes_total, :integer, :default => 0
    add_column :questions, :cached_votes_score, :integer, :default => 0
    add_column :questions, :cached_votes_up, :integer, :default => 0
    add_column :questions, :cached_votes_down, :integer, :default => 0
    add_column :questions, :cached_weighted_score, :integer, :default => 0
    add_column :questions, :cached_weighted_total, :integer, :default => 0
    add_column :questions, :cached_weighted_average, :float, :default => 0.0
    add_index  :questions, :cached_votes_total
    add_index  :questions, :cached_votes_score
    add_index  :questions, :cached_votes_up
    add_index  :questions, :cached_votes_down
    add_index  :questions, :cached_weighted_score
    add_index  :questions, :cached_weighted_total
    add_index  :questions, :cached_weighted_average

    # Uncomment this line to force caching of existing votes
    Question.find_each(&:update_cached_votes)
  end
end
```
assistant