Module: Capistrano::Postgresql::PsqlHelpers
- Defined in:
- lib/capistrano/postgresql/psql_helpers.rb
Instance Method Summary collapse
- #database_exists?(db_name) ⇒ Boolean
- #db_user_exists?(name) ⇒ Boolean
-
#psql(*args) ⇒ Object
returns true or false depending on the remote command exit status.
Instance Method Details
#database_exists?(db_name) ⇒ Boolean
14 15 16 |
# File 'lib/capistrano/postgresql/psql_helpers.rb', line 14 def database_exists?(db_name) psql '-tAc', %Q{"SELECT 1 FROM pg_database WHERE datname='#{db_name}';" | grep -q 1} end |
#db_user_exists?(name) ⇒ Boolean
10 11 12 |
# File 'lib/capistrano/postgresql/psql_helpers.rb', line 10 def db_user_exists?(name) psql '-tAc', %Q{"SELECT 1 FROM pg_roles WHERE rolname='#{name}';" | grep -q 1} end |
#psql(*args) ⇒ Object
returns true or false depending on the remote command exit status
6 7 8 |
# File 'lib/capistrano/postgresql/psql_helpers.rb', line 6 def psql(*args) test :sudo, "-u #{fetch(:pg_system_user)} psql -d #{fetch(:pg_system_db)}", *args end |