lib/prodder/pg.rb in prodder-1.7 vs lib/prodder/pg.rb in prodder-1.7.1
- old
+ new
@@ -50,18 +50,25 @@
where setrole = 0
and datname = '#{db_name}'
SQL
arguments = [
+ '--host', credentials['host'],
+ '--username', credentials['user'],
'-t',
'-c', sql
]
run ['psql', *arguments.push(db_name)] do |out, err, success|
raise PGDumpError.new(err) if !success
File.open(filename, 'w') do |f|
out.each_line do |setting|
- f.write "ALTER DATABASE #{db_name} SET #{setting}" unless setting.gsub(/\s+/, '').empty?
+ unless setting.gsub(/\s+/, '').empty?
+ setting.chomp!
+ setting += "''" if setting.match /.*=$/
+ # using the magic of psql variables through :DBNAME
+ f.puts "ALTER DATABASE :DBNAME SET #{setting};"
+ end
end
end
end
end