Add rake task to migrate investment's internal comments to thread
This commit is contained in:
12
lib/tasks/investments.rake
Normal file
12
lib/tasks/investments.rake
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace :investments do
|
||||||
|
namespace :internal_comments do
|
||||||
|
desc "Migrate internal_comments textarea to a first comment on internal thread"
|
||||||
|
task migrate_to_thread: :environment do
|
||||||
|
comments_author_id = Administrator.first.user.id
|
||||||
|
Budget::Investment.where.not(internal_comments: [nil, '']).find_each do |investment|
|
||||||
|
Comment.create(commentable: investment, user_id: comments_author_id,
|
||||||
|
body: investment.internal_comments, valuation: true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user