Migrate marks to ratings on feedbacks

This commit is contained in:
gregoirenovel 2018-08-27 13:06:04 +02:00
parent 4103861f90
commit e9a262947f

View file

@ -0,0 +1,19 @@
require Rails.root.join("lib", "tasks", "task_helper")
namespace :'2018_08_27_migrate_feedbacks' do
task run: :environment do
MAPPING = {
0 => Feedback.ratings.fetch(:unhappy),
1 => Feedback.ratings.fetch(:neutral),
2 => Feedback.ratings.fetch(:happy)
}
MAPPING.keys.each do |mark|
rating = MAPPING[mark]
Feedback
.where(mark: mark)
.update_all(rating: rating)
end
end
end