socialforge/db/migrate/20160113064153_statics_boar...

15 lines
384 B
Ruby

class StaticsBoardsReply < ActiveRecord::Migration
def up
Project.all.each do |project|
puts project.id
unless project.boards.first.nil?
messages_count = Message.where("board_id =? and parent_id is not ?", project.boards.first.id, nil).count
project.update_attribute(:boards_reply_count, messages_count)
end
end
end
def down
end
end