2012-01-26 22:33:18 +00:00
|
|
|
class AddProjectsCountToUsers < ActiveRecord::Migration
|
|
|
|
def self.up
|
2014-01-21 04:51:49 +00:00
|
|
|
add_column :users, :own_projects_count, :integer, default: 0, null: false
|
2012-01-26 22:33:18 +00:00
|
|
|
|
|
|
|
User.reset_column_information
|
|
|
|
User.all.each do |user|
|
|
|
|
User.reset_counters(user.id, :own_projects)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.down
|
|
|
|
remove_column :users, :own_projects_count
|
|
|
|
end
|
|
|
|
end
|