Commit cf848fd0 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #3217 from chrislawlor/2437

Adds DB-sensitive tablename escape for backup task.
parents 699c9cd4 3df5253c
......@@ -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"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment