summaryrefslogtreecommitdiff
path: root/lib/tasks/gitlab/backup.rake
diff options
context:
space:
mode:
authorChris Lawlor <lawlor.chris@gmail.com>2013-03-14 11:40:09 -0400
committerChris Lawlor <lawlor.chris@gmail.com>2013-03-14 13:30:25 -0400
commit3df5253cc387c97f11e818e3a85fd10b0d17710c (patch)
treed0e0cf4f0e59b5b6a5b3acd877d0a01ce26454eb /lib/tasks/gitlab/backup.rake
parentd2b882fae5dcb9d4072cff9f1d271d378def26c2 (diff)
downloadgitlab-ce-3df5253cc387c97f11e818e3a85fd10b0d17710c.tar.gz
Adds DB-sensitive tablename escape for backup task.
Uses ActiveRecord::Base.connection.quote_table_name. Fixes issue 2437.
Diffstat (limited to 'lib/tasks/gitlab/backup.rake')
-rw-r--r--lib/tasks/gitlab/backup.rake3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/tasks/gitlab/backup.rake b/lib/tasks/gitlab/backup.rake
index 214ce720e7a..32acdcf56b5 100644
--- a/lib/tasks/gitlab/backup.rake
+++ b/lib/tasks/gitlab/backup.rake
@@ -178,8 +178,9 @@ namespace :gitlab do
ActiveRecord::Base.connection.tables.each do |tbl|
print " * #{tbl.yellow} ... "
count = 1
+ safe_tablename = ActiveRecord::Base.connection.quote_table_name(tbl)
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?}
output = {tbl + '_' + count.to_s => line}
file << output.to_yaml.gsub(/^---\n/,'') + "\n"