class DB2Fog::PsqlAdaptor

Public Instance Methods

dump_command(dump_file) click to toggle source
    # File lib/db2fog.rb
134 def dump_command(dump_file)
135   cmd = "pg_dump --clean --format=p --compress=9 #{pg_dump_options}"
136   cmd += " > #{dump_file.path}"
137 end
restore(path) click to toggle source
    # File lib/db2fog.rb
139 def restore(path)
140   run "gunzip -c #{path} | psql #{psql_options}"
141 end

Private Instance Methods

database_options() click to toggle source
    # File lib/db2fog.rb
166 def database_options
167   if DB2Fog.config.respond_to?(:[])
168     DB2Fog.config[:database_options]
169   else
170     raise "DB2Fog not configured"
171   end
172 end
pg_dump_options() click to toggle source
    # File lib/db2fog.rb
145 def pg_dump_options
146   cmd = ''
147   cmd += " -U #{@credentials[:username]} " unless @credentials[:username].nil?
148   cmd += " -h '#{@credentials[:host]}'"    unless @credentials[:host].nil?
149   cmd += " -w"                             if     pg_version >= 9
150   cmd += " #{@credentials[:database]}"
151 end
pg_version() click to toggle source
    # File lib/db2fog.rb
161 def pg_version
162   opts = database_options || {}
163   opts[:pg_version] || 9
164 end
psql_options() click to toggle source
    # File lib/db2fog.rb
153 def psql_options
154   cmd = ''
155   cmd += " -U #{@credentials[:username]} " unless @credentials[:username].nil?
156   cmd += " -h '#{@credentials[:host]}'"    unless @credentials[:host].nil?
157   cmd += " -w"                             if     pg_version >= 9
158   cmd += " -d #{@credentials[:database]}"
159 end