FIX: Remap shouldn't try to change read-only columns

FIX: Remap shouldn’t try to change read-only columns

Read-only columns are obsolete and not used in the code anymore. Previously, remap would fail when trying to update a read-only column.

diff --git a/lib/remap.rb b/lib/remap.rb
index 17ab2d6..d6439fd 100644
--- a/lib/remap.rb
+++ b/lib/remap.rb
@@ -17,10 +17,24 @@ WHERE table_schema='public' and (data_type like 'char%' or data_type like 'text%
     results = cnn.async_exec(sql).to_a
+    model_map = {}
     results.each do |result|
       table_name = result["table_name"]
       column_name = result["column_name"]
+      model = begin
+        model_map[table_name] ||= table_name.camelize.singularize.constantize
+      rescue NameError
+        nil
+      end
+      if model &&
+        model.respond_to?(:ignored_columns) &&
+        model.ignored_columns.include?(column_name)
+        next
+      end
       log "Remapping #{table_name} #{column_name}"
       result = if @regex

GitHub sha: 9cd3f96d

1 Like

Guess I missed that when I did

Oh hmmm, so we have two different implementations of remap. Is there a reason that the script discourse remap command doesn’t use DbHelper?


Not sure, my guess is that you didn’t know about the db_helper.rb file when you did

But even before that it wasn’t using DbHelper.

1 Like

Does this still need a follow up @ZogStriP?

DEV: remove duplicate Remap class and use DbHelper.remap instead