Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
Removed postal_code from CallTool::Target
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrei committed May 26, 2017
1 parent 88816e2 commit 71c9a27
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
3 changes: 1 addition & 2 deletions app/models/call_tool/target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ class CallTool::Target
:phone_extension,
:name,
:title,
:caller_id,
:postal_code # not used
:caller_id

validate :country_is_valid
validates :phone_number, presence: true
Expand Down
23 changes: 23 additions & 0 deletions db/migrate/20170504213048_remove_postal_code_from_targets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class RemovePostalCodeFromTargets < ActiveRecord::Migration
class Call < ActiveRecord::Base; end
class Plugins::CallTool < ActiveRecord::Base; end

def up
batch_size = 300
Call.find_in_batches(batch_size: batch_size) do |group|
group.each do |call|
target = call.read_attribute(:target)
target.delete('postal_code')
call.update!(target: target)
end
end

Plugins::CallTool.find_in_batches(batch_size: batch_size) do |group|
group.each do |call_tool|
targets = call_tool.read_attribute(:targets)
targets.each { |t| t.delete('postal_code') }
call_tool.update!(targets: targets)
end
end
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170425192450) do
ActiveRecord::Schema.define(version: 20170504213048) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down

0 comments on commit 71c9a27

Please sign in to comment.