cirandas.net

ref: master

db/migrate/20140312141805_create_cache_counts_for_profiles.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
class CreateCacheCountsForProfiles < ActiveRecord::Migration
  def self.up
    add_column :profiles, :friends_count, :integer, :null => false, :default => 0
    add_column :profiles, :members_count, :integer, :null => false,  :default => 0
    add_column :profiles, :activities_count, :integer, :null => false,  :default => 0
    add_index :profiles, :friends_count
    add_index :profiles, :members_count
    add_index :profiles, :activities_count
  end

  def self.down
    remove_column :profiles, :friends_count
    remove_column :profiles, :members_count
    remove_column :profiles, :activities_count
    remove_index :profiles, :friends_count
    remove_index :profiles, :members_count
    remove_index :profiles, :activities_count
  end
end