Sha256: 63f8df88d41977703863fc22817acc99892b17520b761a377ec8ebaf5812d0fa
Contents?: true
Size: 788 Bytes
Versions: 3
Compression:
Stored size: 788 Bytes
Contents
# frozen_string_literal: true require 'open3' class PgExport module Adapters class ShellAdapter 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
3 entries across 3 versions & 1 rubygems