Sha256: 092048aca19fe6f544951750d48380cd8989c18e5557f1c1ff517136285d0e17
Contents?: true
Size: 787 Bytes
Versions: 13
Compression:
Stored size: 787 Bytes
Contents
# frozen_string_literal: true require 'open3' class PgExport module Adapters class BashAdapter class PgRestoreError < StandardError; end class PgDumpError < StandardError; end def pg_dump(file, db_name) popen("pg_dump -Fc --file #{file.path} #{db_name}") do |errors| raise PgDumpError, errors.chomp unless errors.empty? end file end def pg_restore(file, db_name) popen("pg_restore -c -d #{db_name} #{file.path}") do |errors| raise PgRestoreError, errors.chomp if /FATAL/ =~ errors end end private def popen(command) Open3.popen3(command) do |_, _, err| errors = err.read yield errors end self end end end end
Version data entries
13 entries across 13 versions & 1 rubygems