From f2cca140b4fe2aa081dffb886310950d4b6c0198 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 8 Sep 2014 14:21:21 -0400 Subject: [PATCH] FIX: Don't break out of remap action if there is a DB error. Display it and continue. --- script/discourse | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/script/discourse b/script/discourse index 551c787dc..4fdc7a6a8 100755 --- a/script/discourse +++ b/script/discourse @@ -29,11 +29,15 @@ WHERE table_schema='public' and (data_type like 'char%' or data_type like 'text% table_name = result["table_name"] column_name = result["column_name"] puts "Remapping #{table_name} #{column_name}" - result = cnn.async_exec("UPDATE #{table_name} - SET #{column_name} = replace(#{column_name}, $1, $2) - WHERE NOT #{column_name} IS NULL - AND #{column_name} <> replace(#{column_name}, $1, $2)", [from, to]) - puts "#{result.cmd_tuples} rows affected!" + begin + result = cnn.async_exec("UPDATE #{table_name} + SET #{column_name} = replace(#{column_name}, $1, $2) + WHERE NOT #{column_name} IS NULL + AND #{column_name} <> replace(#{column_name}, $1, $2)", [from, to]) + puts "#{result.cmd_tuples} rows affected!" + rescue => ex + puts "Error: #{ex}" + end end end