From 09aa5a17cf9ddca705a4742e6245ba6cfad1fc10 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 29 Jan 2018 21:36:27 +0100 Subject: [PATCH] Add rake task to migrate investment's internal comments to thread --- lib/tasks/investments.rake | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lib/tasks/investments.rake diff --git a/lib/tasks/investments.rake b/lib/tasks/investments.rake new file mode 100644 index 000000000..f9619b5ed --- /dev/null +++ b/lib/tasks/investments.rake @@ -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