Class: DB2Fog::PsqlAdaptor

Inherits:
Object
  • Object
show all
Defined in:
lib/db2fog.rb

Instance Method Summary collapse

Constructor Details

#initialize(credentials) ⇒ PsqlAdaptor

Returns a new instance of PsqlAdaptor.



121
122
123
# File 'lib/db2fog.rb', line 121

def initialize(credentials)
  @credentials = credentials
end

Instance Method Details

#dumpObject



125
126
127
128
129
130
131
132
133
# File 'lib/db2fog.rb', line 125

def dump
  dump_file = Tempfile.new("dump")

  cmd = "pg_dump --clean --format=p #{pg_dump_options}"
  cmd += " | gzip -9 > #{dump_file.path}"
  run(cmd)

  dump_file.path
end

#restore(path) ⇒ Object



135
136
137
# File 'lib/db2fog.rb', line 135

def restore(path)
  run "gunzip -c #{path} | psql #{psql_options}"
end