FIX: Don't break out of remap action if there is a DB error. Display it

and continue.
This commit is contained in:
Robin Ward 2014-09-08 14:21:21 -04:00
parent 9964955e88
commit f2cca140b4

View file

@ -29,11 +29,15 @@ WHERE table_schema='public' and (data_type like 'char%' or data_type like 'text%
table_name = result["table_name"] table_name = result["table_name"]
column_name = result["column_name"] column_name = result["column_name"]
puts "Remapping #{table_name} #{column_name}" puts "Remapping #{table_name} #{column_name}"
begin
result = cnn.async_exec("UPDATE #{table_name} result = cnn.async_exec("UPDATE #{table_name}
SET #{column_name} = replace(#{column_name}, $1, $2) SET #{column_name} = replace(#{column_name}, $1, $2)
WHERE NOT #{column_name} IS NULL WHERE NOT #{column_name} IS NULL
AND #{column_name} <> replace(#{column_name}, $1, $2)", [from, to]) AND #{column_name} <> replace(#{column_name}, $1, $2)", [from, to])
puts "#{result.cmd_tuples} rows affected!" puts "#{result.cmd_tuples} rows affected!"
rescue => ex
puts "Error: #{ex}"
end
end end
end end