class PSQLToys::Template::Dumps::Restore
Define toys for PSQL dumps restoring
Public Instance Methods
drop_if_exists()
click to toggle source
# File lib/psql_toys/template/dumps/restore.rb, line 36 def drop_if_exists return unless sh( "psql #{@template.db_access} -l | grep '^\s#{@template.db_config[:database]}\s'" ) exec_tool 'db:dump' exec_tool 'db:drop' end
pg_restore()
click to toggle source
# File lib/psql_toys/template/dumps/restore.rb, line 60 def pg_restore ## https://github.com/rubocop-hq/rubocop/issues/7884 # rubocop:disable Layout/IndentationStyle sh "pg_restore #{@template.db_access} -n public" \ " -d #{@template.db_config[:database]} #{@dump_file.path}" \ ' --jobs=4 --clean --if-exists' # rubocop:enable Layout/IndentationStyle end
restore()
click to toggle source
# File lib/psql_toys/template/dumps/restore.rb, line 45 def restore case @dump_file.format when 'custom' pg_restore when 'plain' ## https://github.com/rubocop-hq/rubocop/issues/7884 # rubocop:disable Layout/IndentationStyle sh "psql #{@template.db_access}" \ " #{@template.db_config[:database]} < #{@dump_file.path}" # rubocop:enable Layout/IndentationStyle else raise 'Unknown DB dump file format' end end