Commit cf848fd06d2d337811dae20e97f480b43f1b8bda
Exists in
master
and in
4 other branches
Merge pull request #3217 from chrislawlor/2437
Adds DB-sensitive tablename escape for backup task.
Showing
1 changed file
with
2 additions
and
1 deletions
Show diff stats
lib/tasks/gitlab/backup.rake
... | ... | @@ -178,8 +178,9 @@ namespace :gitlab do |
178 | 178 | ActiveRecord::Base.connection.tables.each do |tbl| |
179 | 179 | print " * #{tbl.yellow} ... " |
180 | 180 | count = 1 |
181 | + safe_tablename = ActiveRecord::Base.connection.quote_table_name(tbl) | |
181 | 182 | File.open(File.join(backup_path_db, tbl + ".yml"), "w+") do |file| |
182 | - ActiveRecord::Base.connection.select_all("SELECT * FROM `#{tbl}`").each do |line| | |
183 | + ActiveRecord::Base.connection.select_all("SELECT * FROM #{safe_tablename}").each do |line| | |
183 | 184 | line.delete_if{|k,v| v.blank?} |
184 | 185 | output = {tbl + '_' + count.to_s => line} |
185 | 186 | file << output.to_yaml.gsub(/^---\n/,'') + "\n" | ... | ... |