parent
165d5f50c8
commit
05cf2d24dc
@ -0,0 +1,5 @@
|
|||||||
|
class AddMessagesCountToProject < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :projects, :boards_reply_count, :integer, :default => false
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,14 @@
|
|||||||
|
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
|
Loading…
Reference in new issue