mirror of
https://github.com/discourse/discourse.git
synced 2025-06-17 04:42:31 +08: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:
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
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user