Sha256: 24f99a2a71d6c11c7d3d8a7cc17837059aba65911ba182a87d18b7453a15dbee
Contents?: true
Size: 1.31 KB
Versions: 4
Compression:
Stored size: 1.31 KB
Contents
module Storey class GenDumpCommand def self.call( database_url: Storey.configuration.database_url, database: nil, host: nil, username: nil, structure_only: false, file: nil, schemas: nil, password: nil ) switches = {} if database_url.nil? if database.blank? raise ArgumentError, 'database must be supplied' end switches['host'] = host if host.present? switches['username'] = username if username.present? end switches['schema-only'] = nil if structure_only switches['no-privileges'] = nil switches['no-owner'] = nil switches[:file] = Shellwords.escape(file) if schemas schemas = schemas.split(',') schemas_switches = schemas.map do |part| Utils.command_line_switches_from({schema: Shellwords.escape(part) }) end end command_parts = [] if password.present? command_parts << "PGPASSWORD=#{password}" end command_parts << "pg_dump" command_parts << database_url if database_url.present? command_parts += [ Utils.command_line_switches_from(switches), schemas_switches, ] command_parts << database if database_url.blank? command_parts.compact.join(' ') end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
storey-2.2.0 | lib/storey/gen_dump_command.rb |
storey-2.1.2 | lib/storey/gen_dump_command.rb |
storey-2.1.1 | lib/storey/gen_dump_command.rb |
storey-2.1.0 | lib/storey/gen_dump_command.rb |