Class: Avm::Postgresql::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/postgresql/instance.rb,
lib/avm/postgresql/instance/data_unit.rb

Defined Under Namespace

Classes: DataUnit

Instance Method Summary collapse

Constructor Details

#initialize(env, connection_params) ⇒ Instance

Returns a new instance of Instance.



8
9
10
11
# File 'lib/avm/postgresql/instance.rb', line 8

def initialize(env, connection_params)
  @env = env
  @connection_params = connection_params.with_indifferent_access
end

Instance Method Details

#data_unitObject



13
14
15
# File 'lib/avm/postgresql/instance.rb', line 13

def data_unit
  ::Avm::Postgresql::Instance::DataUnit.new(self)
end

#dump_commandObject



17
18
19
20
# File 'lib/avm/postgresql/instance.rb', line 17

def dump_command
  env.command('pg_dump', '--no-privileges', '--clean', '--no-owner', *common_command_args)
     .envvar('PGPASSWORD', password)
end

#dump_gzip_commandObject



22
23
24
# File 'lib/avm/postgresql/instance.rb', line 22

def dump_gzip_command
  dump_command.append(['@ESC_|', 'gzip', '-9', '-c'])
end

#psql_commandObject



26
27
28
# File 'lib/avm/postgresql/instance.rb', line 26

def psql_command
  env.command("@ESC_PGPASSWORD=#{password}", 'psql', *common_command_args)
end

#psql_command_command(sql) ⇒ Object



30
31
32
# File 'lib/avm/postgresql/instance.rb', line 30

def psql_command_command(sql)
  psql_command.append(['--quiet', '--tuples-only', '--command', sql])
end