Module: Avm::EacPostgresqlBase0::Instance::Commands
- Defined in:
- lib/avm/eac_postgresql_base0/instance/commands.rb
Constant Summary collapse
- DUMP_EXCLUDE_PATTERN =
'^(CREATE|COMMENT ON) EXTENSION'
Instance Method Summary collapse
- #common_command_args(database = true) ⇒ Object
- #dump_command ⇒ EacRubyUtils::Envs::Command
- #dump_gzip_command ⇒ EacRubyUtils::Envs::Command
- #gzip_compress_command ⇒ EacRubyUtils::Envs::Command
- #gzip_decompress_command ⇒ EacRubyUtils::Envs::Command
- #load_gzip_command ⇒ EacRubyUtils::Envs::Command
- #password_command_argument ⇒ String
- #psql_command(database = true) ⇒ Object
- #psql_command_command(sql, database = true) ⇒ Object
- #root_psql_command(sql = nil) ⇒ Object
Instance Method Details
#common_command_args(database = true) ⇒ Object
59 60 61 62 |
# File 'lib/avm/eac_postgresql_base0/instance/commands.rb', line 59 def common_command_args(database = true) ['--host', host, '--username', user, '--port', port, (database ? name : MAINTENANCE_DATABASE)] end |
#dump_command ⇒ EacRubyUtils::Envs::Command
13 14 15 16 17 |
# File 'lib/avm/eac_postgresql_base0/instance/commands.rb', line 13 def dump_command env.command('pg_dump', '--no-privileges', '--no-owner', *common_command_args) .envvar('PGPASSWORD', password) .pipe(remove_extensions_ddl) end |
#dump_gzip_command ⇒ EacRubyUtils::Envs::Command
20 21 22 |
# File 'lib/avm/eac_postgresql_base0/instance/commands.rb', line 20 def dump_gzip_command dump_command.pipe(gzip_compress_command) end |
#gzip_compress_command ⇒ EacRubyUtils::Envs::Command
25 26 27 |
# File 'lib/avm/eac_postgresql_base0/instance/commands.rb', line 25 def gzip_compress_command env.command('gzip', '-9', '-c') end |
#gzip_decompress_command ⇒ EacRubyUtils::Envs::Command
30 31 32 |
# File 'lib/avm/eac_postgresql_base0/instance/commands.rb', line 30 def gzip_decompress_command env.command('gzip', '-d') end |
#load_gzip_command ⇒ EacRubyUtils::Envs::Command
35 36 37 |
# File 'lib/avm/eac_postgresql_base0/instance/commands.rb', line 35 def load_gzip_command gzip_decompress_command.pipe(psql_command) end |
#password_command_argument ⇒ String
40 41 42 |
# File 'lib/avm/eac_postgresql_base0/instance/commands.rb', line 40 def password_command_argument "@ESC_PGPASSWORD=#{password}" end |
#psql_command(database = true) ⇒ Object
44 45 46 47 |
# File 'lib/avm/eac_postgresql_base0/instance/commands.rb', line 44 def psql_command(database = true) env.command(password_command_argument, 'psql', '--variable', 'ON_ERROR_STOP=t', *common_command_args(database)) end |
#psql_command_command(sql, database = true) ⇒ Object
49 50 51 |
# File 'lib/avm/eac_postgresql_base0/instance/commands.rb', line 49 def psql_command_command(sql, database = true) psql_command(database).append(['--quiet', '--tuples-only', '--command', sql]) end |
#root_psql_command(sql = nil) ⇒ Object
53 54 55 56 57 |
# File 'lib/avm/eac_postgresql_base0/instance/commands.rb', line 53 def root_psql_command(sql = nil) args = ['sudo', '-u', 'postgres', 'psql'] args += ['--quiet', '--tuples-only', '--command', sql] if sql.present? env.command(*args) end |