Class: DbDumper::Configuration::Postgres

Inherits:
Base
  • Object
show all
Defined in:
lib/db_dumper/configuration/postgres.rb

Instance Attribute Summary

Attributes inherited from Base

#db_config

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from DbDumper::Configuration::Base

Instance Method Details

#copy_data_command(sql, file_path) ⇒ Object



4
5
6
# File 'lib/db_dumper/configuration/postgres.rb', line 4

def copy_data_command(sql, file_path)
  "\\COPY (#{sql}) TO '#{file_path}';"
end

#dump_data_command(dump_data_file_path) ⇒ Object



17
18
19
# File 'lib/db_dumper/configuration/postgres.rb', line 17

def dump_data_command(dump_data_file_path)
  util_command('psql', "#{db_config.dump_copy_options} -c \"#{dump_data_file_path}\"")
end

#dump_schema_command(dump_schema_file_path) ⇒ Object



8
9
10
# File 'lib/db_dumper/configuration/postgres.rb', line 8

def dump_schema_command(dump_schema_file_path)
  util_command('pg_dump', "#{db_config.dump_schema_options} -f #{dump_schema_file_path}")
end

#dump_table_data_command(dumped_tables, dump_table_data_file_path) ⇒ Object



12
13
14
15
# File 'lib/db_dumper/configuration/postgres.rb', line 12

def dump_table_data_command(dumped_tables, dump_table_data_file_path)
  joined_tables = "-t #{dumped_tables.join(' -t ')}"
  util_command('pg_dump', "#{db_config.dump_data_options} #{joined_tables} -f #{dump_table_data_file_path}")
end