Class: Avm::Stereotypes::Postgresql::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/stereotypes/postgresql/instance.rb,
lib/avm/stereotypes/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.



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

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

Instance Method Details

#data_unitObject



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

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

#dump_commandObject



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

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

#dump_gzip_commandObject



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

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

#psql_commandObject



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

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

#psql_command_command(sql) ⇒ Object



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

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