Sha256: 891bf5f0914ba01bf88a8e46fa32a2ff2cad7cc96d9bb54cec6f33a7f2d2694c
Contents?: true
Size: 1.15 KB
Versions: 3
Compression:
Stored size: 1.15 KB
Contents
module Dumper module Database class PostgreSQL < Base DUMP_TOOL = 'pg_dump' FILE_EXT = 'sql.gz' def command "cd #{tmpdir} && #{password_variable} #{dump_tool_path} #{connection_options} #{@config[:database]} | gzip > #{filename}" end def connection_options [ :host, :port, :socket ].map do |option| next if @config[option].blank? "--#{option}='#{@config[option]}'".gsub('--socket', '--host') end.compact.join(' ') end def password_variable @config[:password].blank? ? '' : "PGPASSWORD='#{@config[:password]}'" end def set_config_for(rails_env=nil) return unless defined?(ActiveRecord::Base) && ActiveRecord::Base.configurations && (config = ActiveRecord::Base.configurations[rails_env]) && (config['adapter'] == 'postgresql') @config = { :host => config['host'], :port => config['port'], :username => config['username'], :password => config['password'], :database => config['database'], :dump_tool => dump_tool_path } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dumper-1.1.2 | lib/dumper/database/postgresql.rb |
dumper-1.1.1 | lib/dumper/database/postgresql.rb |
dumper-1.1.0 | lib/dumper/database/postgresql.rb |