From d18fb5e6be46feb9c01920732bff374ffc36e299 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 8 Mar 2016 15:46:48 +0200 Subject: [PATCH] Story#114871365 - add rake task to update contacts country code --- lib/tasks/convert.rake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/tasks/convert.rake b/lib/tasks/convert.rake index ba0e547dc..849450c7c 100644 --- a/lib/tasks/convert.rake +++ b/lib/tasks/convert.rake @@ -32,5 +32,21 @@ namespace :convert do d.save! end end + + + desc 'Contact Address Country Code Upcase' + task country_code_ucase: :environment do + count = 0 + Contact.find_each do |c| + if c.country_code.present? && c.country_code != c.country_code.upcase + c.country_code = c.country_code.upcase + c.update_columns(country_code: c.country_code.upcase) + # c.send(:record_update) + + count +=1 + puts "#{count} contacts has been changed" if count % 1000 == 0 + end + end + end end