diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-03-16 02:26:01 -0700 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-03-16 02:26:01 -0700 |
commit | cf848fd06d2d337811dae20e97f480b43f1b8bda (patch) | |
tree | 8da39ad00b37fab8976c0be9e988e918238b9766 /lib | |
parent | 699c9cd4999335212678e26d2d86a10e22d0eb29 (diff) | |
parent | 3df5253cc387c97f11e818e3a85fd10b0d17710c (diff) | |
download | gitlab-ce-cf848fd06d2d337811dae20e97f480b43f1b8bda.tar.gz |
Merge pull request #3217 from chrislawlor/2437
Adds DB-sensitive tablename escape for backup task.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tasks/gitlab/backup.rake | 3 |
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" |