mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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.
This commit is contained in:
parent
b690fc3d98
commit
9cd3f96dee
14
lib/remap.rb
14
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
|
results = cnn.async_exec(sql).to_a
|
||||||
|
|
||||||
|
model_map = {}
|
||||||
|
|
||||||
results.each do |result|
|
results.each do |result|
|
||||||
table_name = result["table_name"]
|
table_name = result["table_name"]
|
||||||
column_name = result["column_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}"
|
log "Remapping #{table_name} #{column_name}"
|
||||||
|
|
||||||
result = if @regex
|
result = if @regex
|
||||||
|
Loading…
Reference in New Issue
Block a user