Module: Avm::EacPostgresqlBase0::Instance::Commands
- Defined in:
- lib/avm/eac_postgresql_base0/instance/commands.rb
Constant Summary collapse
- DUMP_EXCLUDE_PATTERNS =
['(CREATE|COMMENT ON) EXTENSION', 'SET default_table_access_method'].freeze
Instance Method Summary collapse
-
#common_command_args(database = true) ⇒ Object
rubocop:disable Style/OptionalBooleanParameter.
- #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
rubocop:disable Style/OptionalBooleanParameter.
-
#psql_command_command(sql, database = true) ⇒ Object
rubocop:disable Style/OptionalBooleanParameter.
- #root_psql_command(sql = nil) ⇒ Object
Instance Method Details
#common_command_args(database = true) ⇒ Object
rubocop:disable Style/OptionalBooleanParameter
59 60 61 62 |
# File 'lib/avm/eac_postgresql_base0/instance/commands.rb', line 59 def common_command_args(database = true) # rubocop:disable Style/OptionalBooleanParameter ['--host', host, '--username', user, '--port', port, (database ? name : MAINTENANCE_DATABASE)] end |
#dump_command ⇒ EacRubyUtils::Envs::Command
14 15 16 17 |
# File 'lib/avm/eac_postgresql_base0/instance/commands.rb', line 14 def dump_command DUMP_EXCLUDE_PATTERNS .inject(pg_dump_command) { |a, e| a.pipe(exclude_pattern_command(e)) } 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
rubocop:disable Style/OptionalBooleanParameter
44 45 46 47 |
# File 'lib/avm/eac_postgresql_base0/instance/commands.rb', line 44 def psql_command(database = true) # rubocop:disable Style/OptionalBooleanParameter env.command(password_command_argument, 'psql', '--variable', 'ON_ERROR_STOP=t', *common_command_args(database)) end |
#psql_command_command(sql, database = true) ⇒ Object
rubocop:disable Style/OptionalBooleanParameter
49 50 51 |
# File 'lib/avm/eac_postgresql_base0/instance/commands.rb', line 49 def psql_command_command(sql, database = true) # rubocop:disable Style/OptionalBooleanParameter 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 |