mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 10:55:25 +08:00
FIX: don't remap readonly columns
This commit is contained in:
parent
d82da69c2c
commit
bfcbfd7864
|
@ -9,13 +9,24 @@ class DbHelper
|
|||
ORDER BY table_name, column_name
|
||||
SQL
|
||||
|
||||
TRIGGERS_SQL ||= <<~SQL
|
||||
SELECT trigger_name
|
||||
FROM information_schema.triggers
|
||||
WHERE trigger_name LIKE '%_readonly'
|
||||
SQL
|
||||
|
||||
def self.remap(from, to, anchor_left: false, anchor_right: false, excluded_tables: [])
|
||||
like = "#{anchor_left ? '' : "%"}#{from}#{anchor_right ? '' : "%"}"
|
||||
|
||||
triggers = DB.query(TRIGGERS_SQL).map(&:trigger_name).to_set
|
||||
|
||||
text_columns = Hash.new { |h, k| h[k] = [] }
|
||||
|
||||
DB.query(REMAP_SQL).each do |r|
|
||||
unless triggers.include?("#{r.table_name}_#{r.column_name}_readonly")
|
||||
text_columns[r.table_name] << r.column_name
|
||||
end
|
||||
end
|
||||
|
||||
text_columns.each do |table, columns|
|
||||
next if excluded_tables.include?(table)
|
||||
|
@ -39,11 +50,15 @@ class DbHelper
|
|||
end
|
||||
|
||||
def self.regexp_replace(pattern, replacement, flags: "gi", match: "~*", excluded_tables: [])
|
||||
triggers = DB.query(TRIGGERS_SQL).map(&:trigger_name).to_set
|
||||
|
||||
text_columns = Hash.new { |h, k| h[k] = [] }
|
||||
|
||||
DB.query(REMAP_SQL).each do |r|
|
||||
unless triggers.include?("#{r.table_name}_#{r.column_name}_readonly")
|
||||
text_columns[r.table_name] << r.column_name
|
||||
end
|
||||
end
|
||||
|
||||
text_columns.each do |table, columns|
|
||||
next if excluded_tables.include?(table)
|
||||
|
|
Loading…
Reference in New Issue
Block a user