Class: CucumberTree::Handler::Database::Postgresql

Inherits:
Base
  • Object
show all
Defined in:
lib/cucumber_tree/handlers/databases/postgresql.rb

Instance Attribute Summary

Attributes inherited from Base

#scenario, #world

Instance Method Summary collapse

Methods inherited from Base

#page

Instance Method Details

#load(snapshot) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/cucumber_tree/handlers/databases/postgresql.rb', line 7

def load(snapshot)
  dump_file = snapshot[:postgres_file]
  options = []
  options << "-U #{db_config['username']}" if db_config['username'].present?
  options << "-d #{db_config['database']}"
  options << "-f #{dump_file}"
  `psql #{options.join(' ')}`
end

#save(snapshot) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/cucumber_tree/handlers/databases/postgresql.rb', line 16

def save(snapshot)
  dump_file = ::CucumberTree::TempDir.file_name("postgres.dump")
  options = []
  options << "-f #{dump_file}"
  options << "-U #{db_config['username']}" if db_config['username'].present?
  options << "--exclude-table=schema_migrations"
  options << "-a #{db_config['database']}"
  `pg_dump #{options.join(' ')}`
  snapshot[:postgres_file] = dump_file
end