class AddPraisesCountForJouranlsForMessages < ActiveRecord::Migration[5.2]
  def change
    add_column :journals_for_messages, :praises_count, :integer, :default => 0

    messages = JournalsForMessage.includes(:praise_treads).all
    messages.find_each do |m|
      puts("####{m.id}")
      praises_count = m.praise_treads.liker.count
      m.update_column(:praises_count, praises_count)
    end

  end
end
