Sha256: 47c476af5133bc83649e71025e5bbd21abd0bf7f6cab1402e1ddaeb44aa6f06e

Contents?: true

Size: 804 Bytes

Versions: 3

Compression:

Stored size: 804 Bytes

Contents

module Dbcp
  class PostgresDatabase < Database
    def export_command(snapshot_file)
      build_password + [
        'pg_dump',
        '--host',     host,
        build_port,
        '--username', username,
        '--file',     snapshot_file.path,
        '--format',   'c',
        database
      ].flatten.compact.shelljoin
    end

    def import_command(snapshot_file)
      build_password + [
        'pg_restore',
        '--host',     host,
        build_port,
        '--username', username,
        '--dbname',   database,
        '--clean',
        snapshot_file.path
      ].flatten.compact.shelljoin
    end

    private

    def build_password
      %W[export PGPASSWORD=#{password}].shelljoin + '; '
    end

    def build_port
      ['--port', port] if host && port
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dbcp-0.2.1 lib/dbcp/databases/postgres_database.rb
dbcp-0.2.0 lib/dbcp/databases/postgres_database.rb
dbcp-0.1.0 lib/dbcp/databases/postgres_database.rb