Forum: Ruby on Rails migration: counter cache & "reset_column_information"

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B45eab4f18aa1bb2a44d6e657531a642?d=identicon&s=25 Alain Ravet (aravet)
on 2005-12-15 01:09
To speed up

  <%=   @project.members_count   %>

, I added a counter cache to the 'projects' table with the migration
below:

  def self.up
    add_column "projects", "members_count", :string, :default => "0"
    Project.reset_column_information
    Project.find(:all).each do |p|
      p.update_attribute :members_count , p.members.count
    end
  end


Question:
   Is "Project.reset_column_information" required in the migration?

Alain


(Note: For info, I modified the 'Member' model accordingly:
      class Member < ActiveRecord::Base
             belongs_to :project, :counter_cache => true
)
B45eab4f18aa1bb2a44d6e657531a642?d=identicon&s=25 Alain Ravet (aravet)
on 2005-12-16 00:10
Anybody?
This topic is locked and can not be replied to.