X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/5cbd4038edb32b0304bd766e70fc680ea447b52b..8eca904388361aff879b379fbe3901a67275efb9:/lib/tasks/add_version_to_nodes.rake?ds=sidebyside diff --git a/lib/tasks/add_version_to_nodes.rake b/lib/tasks/add_version_to_nodes.rake index f86961904..11f639abd 100644 --- a/lib/tasks/add_version_to_nodes.rake +++ b/lib/tasks/add_version_to_nodes.rake @@ -1,17 +1,17 @@ -namespace 'db' do - desc 'Adds a version number to the nodes table' - task :node_version do - require File.dirname(__FILE__) + '/../../config/environment' +namespace "db" do + desc "Adds a version number to the nodes table" + task :node_version do + require File.dirname(__FILE__) + "/../../config/environment" increment = 1000 offset = 0 - id_max = OldNode.find(:first, :order => 'id desc').id + id_max = OldNode.find(:first, :order => "id desc").id while offset < (id_max + increment) hash = {} # should be offsetting not selecting - OldNode.find(:all, :limit => increment, :offset => offset, :order => 'timestamp').each do |node| + OldNode.find(:all, :limit => increment, :offset => offset, :order => "timestamp").each do |node| hash[node.id] ||= [] hash[node.id] << node end @@ -28,7 +28,7 @@ namespace 'db' do temp_old_node.timestamp = node.timestamp temp_old_node.tile = node.tile temp_old_node.version = n - temp_old_node.save! || fail + temp_old_node.save! || raise n += 1 end end