Adds DB-sensitive tablename escape for backup task.
Uses ActiveRecord::Base.connection.quote_table_name. Fixes issue 2437.
This commit is contained in:
parent
d2b882fae5
commit
3df5253cc3
1 changed files with 2 additions and 1 deletions
|
@ -178,8 +178,9 @@ namespace :gitlab do
|
||||||
ActiveRecord::Base.connection.tables.each do |tbl|
|
ActiveRecord::Base.connection.tables.each do |tbl|
|
||||||
print " * #{tbl.yellow} ... "
|
print " * #{tbl.yellow} ... "
|
||||||
count = 1
|
count = 1
|
||||||
|
safe_tablename = ActiveRecord::Base.connection.quote_table_name(tbl)
|
||||||
File.open(File.join(backup_path_db, tbl + ".yml"), "w+") do |file|
|
File.open(File.join(backup_path_db, tbl + ".yml"), "w+") do |file|
|
||||||
ActiveRecord::Base.connection.select_all("SELECT * FROM `#{tbl}`").each do |line|
|
ActiveRecord::Base.connection.select_all("SELECT * FROM #{safe_tablename}").each do |line|
|
||||||
line.delete_if{|k,v| v.blank?}
|
line.delete_if{|k,v| v.blank?}
|
||||||
output = {tbl + '_' + count.to_s => line}
|
output = {tbl + '_' + count.to_s => line}
|
||||||
file << output.to_yaml.gsub(/^---\n/,'') + "\n"
|
file << output.to_yaml.gsub(/^---\n/,'') + "\n"
|
||||||
|
|
Loading…
Reference in a new issue